apt install apache2 php ssl
<html><head></head><body>index.php
<h2>Hello World</h2>
</body><html>
<?php
print "Hello World";
Hello World
and
Hello World
Not exciting and it shows that the web server and PHP are working
I wanted to move the default location for html documents from
/var/www/html to /home/pi/www/html just to make it easier to mess
with files in the pi home directory.
This gives permissions for this directory.<Directory /home/pi/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
DocumentRoot /var/www/html
to
DocumentRoot /home/pi/www/html
We need to enable SSL because, remember, location will not work
unless the requester is https. Hence the install of openssl
above
sudo openssl req -new -x509 -days 365 -nodes -out /etc/ssl/localcerts/apache.pem -keyout /etc/ssl/localcerts/apache.key
Add the following after the existing VirtualHost section for port 80
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /home/pi/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/etc/ssl/localcerts/apache.pem"
SSLCertificateKeyFile "/etc/ssl/localcerts/apache.key"
</VirtualHost>
Add the apache ssl module:
sudo a2enmod ssl
This creates the following links in /etc/apache2/mods-enabled
lrwxrwxrwx 1 root root 26 Jan 16 15:38 ssl.conf -> ../mods-available/ssl.conf:
lrwxrwxrwx 1 root root 26 Jan 16 15:38 ssl.load -> ../mods-available/ssl.load
systemctl restart apache2.serviceRestart the apache server: