How should I set my domain.conf file with SSL port

Dear All

I have just install Let's Encrpyt SSL on my VPS. and I just modify my file on /etc/apache2/sites-available# nano mydomain.com.conf as follows. However It appear ERROR, would you please teach my how to make my conf Correctly with SSL port ? thank you. Because I am a beginner, I still have much to learn. Thank you


<virtualhost *:80=""></virtualhost>

    ServerName mydomain.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/Chikan

<directory "="" chikan"="" html="" var="" www=""> AllowOverride All </directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

<virtualhost *:443=""></virtualhost>

SSLEngine On

ServerName mydomain.com
ServerAdmin webmaster@localhost

DocumentRoot /var/www/html/Chikan

<directory "="" chikan"="" html="" var="" www=""> AllowOverride All </directory>

ErrorLog ${APACHELOGDIR}/error.log
CustomLog ${APACHELOGDIR}/access.log combined

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


1 Reply

Hi there,

What's the "ERROR" you're seeing? Can you paste it here?

You can get tips on what might be wrong with your configuration with this command:

apache2ctl configtest

Looking over your config I am seeing a lot wrong. You have many directives that should be nested inside the <virtualhost> blocks, outside of them. Try something like this instead:

<VirtualHost *:80>
        ServerName mydomain.com
        ServerAlias www.mydomain.com

        RewriteEngine on
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

        ErrorLog ${APACHE_LOG_DIR}/redirect-error.log
        CustomLog ${APACHE_LOG_DIR}/redirect-access.log combined

</VirtualHost>

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                SSLEngine On
                SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
                Include /etc/letsencrypt/options-ssl-apache.conf

                ServerName mydomain.com
                ServerAlias www.mydomain.com

                ErrorLog ${APACHE_LOG_DIR}/ssl-error.log
                CustomLog ${APACHE_LOG_DIR}/ssl-access.log combined

                DocumentRoot  /var/www/html/Chikan
        </VirtualHost>
</IfModule>

By the way to format your question better you should surround the config file you pasted with three 'backticks' on the top and bottom. It'll make it much easier for us to read. This page has easy to read formatting examples:

https://en.support.wordpress.com/markdown-quick-reference/

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct