ตั้งค่า Apache2 HTTP With Self-Signed SSL/TLS Certificates On Ubuntu 16.04 LTS Servers

เราจะไม่ได้พูดถึงติดตั้ง apache2 นะ โดยมีคำสั่งดังนี้

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/example.com.key -out /etc/ssl/certs/example.com.crt

จากนั้น

vi /etc/apache2/sites-available/default-ssl.conf

จากนั้น ตั้งค่า

<IfModule mod_ssl.c>
 <VirtualHost _default_:443>       
                ServerAdmin webmaster@localhost
                ServerName example.com
                ServerAlias www.example.com
                DocumentRoot /var/www/html

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

                #Include conf-available/serve-cgi-bin.conf

                #   SSL Engine Switch:
                #   Enable/Disable SSL for this virtual host.
                SSLEngine on
                SSLCertificateFile      /etc/ssl/certs/example.com.crt
                SSLCertificateKeyFile /etc/ssl/private/example.com.key
                #
                #SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
                #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

......................
.......................

 </VirtualHost>
</IfModule>
จากนั้น

vi /etc/apache2/sites-available/000-default.conf

จากนั้นตั้งค่า

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        
        ServerName example.com
        ServerAlias www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

..................
.................
</VirtualHost>
จากนั้น
sudo apachectl configtest
sudo a2enmod ssl
sudo a2ensite default-ssl

จากนั้น
systemctl restart apache2.service

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *