Question

correct apache2 virtual host config

I was a dummy and started making changes to the 000-default-ls-ssl.conf file without a back up.

Here is what I think the file should be with the actual domain name changed to example.com.

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem 
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem 
Include /etc/letsencrypt/options-ssl-apache.conf 
ServerName example.com 
</VirtualHost> 

If I run apachectl -t as a not root user with SUDO it says that there is a snytax error in the line with the SSLCertifcateFile. It also says that the fullchain.pem file does not exist.

But if I run the same command as root it says syntax is ok?

1st is the config ok? 2nd should the sudo user and root test the config the same?

One last question. I have been reading that it is better to place the items that are normally in the hraccess file in the apache conf since it makes apache faster??? What does the experts on here think?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

@smsmail

The non-root user does not have permissions to read some of the files included in your configuration, that is why it gives an error.

The .htaccess file is read on every single request which causes bad performance while configuration is only read when server starts or is reloaded that is why it is better to put the config options in the configuration file especially for production environments.

Hope this helps.

Thanks, that is what I thought was going on but wanted to check.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.