Apache, PHP, and PostgreSQL
This document describes how to set up the Apache web server on an Arch Linux system. It also tells how to optionally install PHP and PostgreSQL and integrate these in the Apache server.
# pacman -Sy # pacman -S apache # pacman -S php # pacman -S postgresql
If you like, you can install just apache, apache and php, or all three. This document assumes you will install all three, but if you wish, you can stop after any of the sections.
- Add line to
/etc/hosts(If the file doesn't exist, create it)
127.0.0.1 localhost.localdomain localhost
Note: if you want a different hostname, append it to the end:
127.0.0.1 localhost.localdomain localhost myhostname
If you set a hostname in step one, the hostame variable should be the same. otherwise localhost:
# # Networking # HOSTNAME="localhost"
- Run in terminal (as root):
# /etc/rc.d/httpd start
- Apache should now be running. Test by visiting http://localhost/ in a web browser. It displays a simple Arch Linux home page.
/etc/rc.conf(to start Apache at boot):
Daemons=(some daemons now add httpd)
Or add this line to
- If you want user directories (ie: ~/public_html on the machine is accessed as http://localhost/~user/) to be available on the web, uncomment the following lines in /etc/httpd/conf/httpd.conf:
<Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI <Limit GET POST OPTIONS PROPFIND> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS PROPFIND> Order deny,allow Deny from all </LimitExcept> </Directory>
PHP is practically available out of the box now.
- Uncomment this line in
#LoadModule php5_module lib/apache/libphp5.so
- Restart Apache Server to make changes take effect (as root):
# /etc/rc.d/httpd restart
- Test PHP with a simple, but very informational script:
<html> <head> <title>PHP Test Page</title> </head> <body> <p> This is Arch Linux, running PHP. </p> <p> <?php phpinfo(); ?> </p> </body> </html>
Save this file as "test.php" and copy to
/home/httpd/html/ or to
~/public_html if you permitted such a configuration. Also remember to make it executable (chmod a+x test.php).
- Test PHP:
Do these only if you want PostgreSQL support
/etc/php.ini(this is in
/usr/etcon older systems) to uncomment the following line:
work in progress