computers:apache_server_configuration
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
computers:apache_server_configuration [2017/08/28 22:21] – [HTTPS/SSL] chkuo | computers:apache_server_configuration [2022/11/02 16:04] (current) – chkuo | ||
---|---|---|---|
Line 5: | Line 5: | ||
<code bash> | <code bash> | ||
- | sudo apt-get install apache2 | + | sudo apt install apache2 |
- | sudo apt-get install | + | sudo apt install |
</ | </ | ||
- | ===== Apache | + | ===== Process control and status check ===== |
- | To start/ | + | |
<code bash> | <code bash> | ||
- | sudo / | + | sudo systemctl |
- | sudo / | + | sudo systemctl |
- | sudo / | + | sudo systemctl |
+ | sudo systemctl status apache2 | ||
</ | </ | ||
- | the configuration file is: ''/ | + | ===== Configuration ===== |
+ | * the configuration file is: ''/ | ||
+ | * Directory listing | ||
+ | * To disable directory listing | ||
+ | * add '' | ||
+ | * To enable directory listing in a specific directory | ||
+ | * add a '' | ||
+ | * Within the '' | ||
+ | * Sample configuration: | ||
<file 000-default.conf> | <file 000-default.conf> | ||
Line 84: | Line 93: | ||
</ | </ | ||
- | ===== HTTPS/ | + | ===== Update |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
+ | <code bash> | ||
+ | # for Ubuntu 20.04.5 LTS; 2022/11/02 | ||
+ | # to update beyond Apache/ | ||
+ | $ apache2 -v | ||
+ | Server version: Apache/ | ||
+ | Server built: | ||
+ | $ sudo add-apt-repository ppa: | ||
+ | $ sudo apt update | ||
+ | $ sudo apt install apache2 | ||
+ | $ apache2 -v | ||
+ | Server version: Apache/ | ||
+ | Server built: | ||
+ | $ systemctl status apache2 | ||
+ | $ sudo systemctl start apache2 | ||
+ | $ sudo systemctl enable apache2 | ||
+ | </ | ||
- | ==== Directory listing ==== | + | ===== Password protection |
- | * disable directory listing by specifying '' | + | |
- | * to enable directory listing in a specific directory, add a '' | + | |
- | + | ||
- | ==== Password protection ==== | + | |
Inside the directory to be protected, add a '' | Inside the directory to be protected, add a '' | ||
<code bash> | <code bash> | ||
Line 112: | Line 130: | ||
+ | ===== HTTPS/SSL ===== | ||
+ | * Use [[https:// | ||
+ | * install: | ||
+ | <code bash> | ||
+ | # require snapd; pre-installed on Ubuntu 20.04 | ||
+ | # remove the pre-installed cerbot (if present) | ||
+ | $ sudo apt remove certbot | ||
+ | # install certbot using snap | ||
+ | $ sudo snap install --classic certbot | ||
+ | # get a certificate; | ||
+ | # (1) get a certificate without changing the Apache configuration | ||
+ | $ sudo certbot certonly --apache | ||
+ | # (2) get a certificate and have certbot edit the Apache configuration | ||
+ | $ sudo certbot --apache | ||
+ | # | ||
+ | # check status | ||
+ | $ sudo systemctl status certbot.timer | ||
+ | # test renewal | ||
+ | $ sudo certbot renew --dry-run | ||
+ | # manual renewal; not recommended | ||
+ | # better to put '/ | ||
+ | $ sudo certbot renew | ||
+ | # enable ssl | ||
+ | $ sudo a2enmod ssl | ||
+ | </ | ||
+ | * modify ''/ | ||
+ | < | ||
+ | ServerName example.com | ||
+ | ServerAdmin admin@example.com | ||
+ | </ | ||
+ | * SSL test: [[https:// | ||
===== PHP ===== | ===== PHP ===== | ||
==== Info ==== | ==== Info ==== | ||
Line 154: | Line 202: | ||
==== Permissions ==== | ==== Permissions ==== | ||
- | Make the permissions more restrictive for security reasons. Assuming the wiki is installed in ''/ | + | Make the permissions more restrictive for security reasons. Assuming |
<code bash> | <code bash> | ||
# change the ownership | # change the ownership | ||
- | sudo chown -R www-data:admin / | + | sudo chown -R www-data:adm / |
# restrict access by other | # restrict access by other | ||
sudo chmod -R o-rwx / | sudo chmod -R o-rwx / | ||
Line 180: | Line 228: | ||
sudo mkdir -p / | sudo mkdir -p / | ||
# change ownership | # change ownership | ||
- | sudo chown -R www-data:admin / | + | sudo chown -R www-data:adm / |
# configure the virtual host For WebDAV | # configure the virtual host For WebDAV | ||
# create the WebDAV password file with the user test | # create the WebDAV password file with the user test | ||
Line 186: | Line 234: | ||
sudo htpasswd -c / | sudo htpasswd -c / | ||
# change the ownership and permissions | # change the ownership and permissions | ||
- | sudo chown www-data:admin / | + | sudo chown www-data:adm / |
sudo chmod 640 / | sudo chmod 640 / | ||
# backup the vhost configuration | # backup the vhost configuration | ||
Line 221: | Line 269: | ||
==== References ==== | ==== References ==== | ||
- | * [[http://www.howtoforge.com/ | + | * [[https://www.digitalocean.com/ |
- | * [[http://www.linuxserver.org/linux/ubuntu/webdav-ubuntu-10-04/]] | + | * [[https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04]] |
computers/apache_server_configuration.1503930091.txt.gz · Last modified: 2017/08/28 22:21 by chkuo