Apache a powerful and the most popular web server. It makes a great choice for anything from a powerful production server to a small personal home server. It is often installed as part of LAMP web service solution stack.
Install Apache Web Server
Install from the official repository.
sudo pacman -S apache
Configure Apache Web Server
Open the configuration file.
sudo nano /etc/httpd/conf/httpd.conf
Default user and group are set to
http and can be changed with
Group options respectively. Administrator email address is defines with
ServerAdmin option. The default location where the web pages are accessed from is
/srv/http. This value can be changed with
DocumentRoot option in which case
<Directory> values should also be changed appropriately.
Enable TLS / SSL
Add or uncomment the following lines and save the file.
Listen 443 LoadModule ssl_module modules/mod_ssl.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so Include conf/extra/httpd-vhosts.conf
By default the port is set by
Listen 80 option. Multiple ports can be listened to by adding an option for each port such as
Listen 443 for SSL connections. The last line is optional and can be left commented out. Virtual hosts can instead be added to the main configuration as opposed to the supplementary configuration file.
Setup a default Web Directory
Copy the directory directive changing the options and values as needed. Each directory or sub-directory can have it’s own directive with distinct settings.
<Directory "/mnt/web"> AllowOverride All Options Indexes FollowSymLinks </Directory>
<Directory> tags options can be added that are specific to that directory or all directories if the path is not specified.
Options directive can be used to define options like
Indexes which allows listing of directories and files or
FollowSymLinks which allows symbolic links. If
.htaccess files are to be used
AllowOverride should be should be set to
All otherwise value of
None is recommended.
DocumentRoot option was changed to a new directory then create it to store website files.
sudo mkdir /mnt/web
Change the owner and group of the document root directory.
sudo chown -R http:http /mnt/web
Change the permissions of the document root directory.
sudo chmod -R 775 /mnt/virtual/web
Start Apache Web Server
Start the service.
sudo systemctl start httpd
Enable the service to run at boot.
sudo systemctl enable httpd
Once successfully installed it may be desirable to configure Apache user passwords to prevent unauthorized access to the server. To complete the LAMP server also install MySQL / MariaDB and install PHP. Optionally also install phpMyAdmin.