Editing Vhost file creates errors and apache2 doesn't work after

They’re redirecting to https://www

Yes there is a new file :smiley: Here it is!

<VirtualHost *:443>
servername elami.mk
serveralias www.elami.mk *.elami.mk
ServerAdmin webmaster@elami.mk

    DocumentRoot /home/elami_mk/www/public_html
    <Directory />
            require all granted
            Options FollowSymLinks
            AllowOverride None
            Options +Indexes +FollowSymLinks +MultiViews +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>

    <IfModule mod_fastcgi.c>
            AddHandler php7-fcgi .php
            Action php7-fcgi /php7-fcgi
            Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
            FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php7.3-fpm-elami_mk.sock -pass-header Authorization
            <Directory /usr/lib/cgi-bin>
                    require all granted
            </Directory>
    </IfModule>

    <FilesMatch \.php$>
            SetHandler "proxy:unix:/var/run/php7.3-fpm-elami_mk.sock|fcgi://localhost/"
                    </FilesMatch>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    ErrorLog ${APACHE_LOG_DIR}/web_website_url.log

    # Possible values include: debug, info, notice, warn, error, crit,
           AddHandler php7-fcgi .php
            Action php7-fcgi /php7-fcgi
            Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
            FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php7.3-fpm-elami_mk.sock -pass-header Authorization
            <Directory /usr/lib/cgi-bin>
                    require all granted
            </Directory>
    </IfModule>

    <FilesMatch \.php$>
            SetHandler "proxy:unix:/var/run/php7.3-fpm-elami_mk.sock|fcgi://localhost/"
                    </FilesMatch>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    ErrorLog ${APACHE_LOG_DIR}/web_website_url.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel error
    CustomLog ${APACHE_LOG_DIR}/web_website_url.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/elami.mk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/elami.mk/privkey.pem

You are welcome.
But we are not done yet.
Now that you got the secure site up.
You need to decide if you want to redirect all traffic to HTTPS.
And also to which name www or no www.

Essentially there exist four sites:
http://site
http://www.site
https://site
https://www.site
Three should redirect and end up at the fourth one.
[you need to decide which]

If it doesn't matter then I would choose

https://site

for the sake of simplicity :slight_smile:

The * won't work so well with HTTPS.
The cert only has two names in it.
So replace those lines with:
servername elami.mk
serveralias www.elami.mk

And then give you site a full once over at:
https://check-your-website.server-daten.de/
and at https://www.ssllabs.com/

Let’s review the redirection code in use:
http site has:
RedirectMatch permanent ^/(.*)$ http://elami.mk/$1
But that is being ignored and overridden by:
X-Redirect-By: WordPress
Location: http://www.elami.mk/

https site has:
? ? ?

I believe I fixed it

https://elami.mk/
HTTP/1.1 301 Moved Permanently
X-Redirect-By: WordPress
Location: https://www.elami.mk/

Seems contrary to your instinct but it works just as well.
[and can be reversed at any time - the cert will allow either name]

Ahh I see :slight_smile: I will leave as is but I know where to change it now. Thank you very much!!!

1 Like

rinse and repeat for the other sites…
cheers

1 Like

You are a life saver!
I owe you!

Thank you

Feel free to donate to LetsEncrypt [https://letsencrypt.org/donate/]
And/Or just buy me a beer (virtually) [https://beer4.work/]
[rest assured I will drink it in your honor - LOL]

1 Like

There

https://community.letsencrypt.org/t/deleted-certificates-manually-now-i-get-apache2ctl-configtest-error-and-websites-are-down/101945?u=juergenauer

is your topic.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.