From ArchWiki
Revision as of 19:06, 26 July 2005 by Luke (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

Install Packages

  # 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.

Configure Apache

  • Add line to /etc/hosts (If the file doesn't exist, create it)  localhost.localdomain   localhost

Note: if you want a different hostname, append it to the end:  localhost.localdomain   localhost myhostname
  • Edit /etc/rc.conf:

If you set a hostname in step one, the hostame variable should be the same. otherwise localhost:

  # Networking
  • 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.
  • Edit /etc/rc.conf (to start Apache at boot):
  Daemons=(some daemons now add httpd)

Or add this line to rc.local:

  /etc/rc.d/httpd start
  • 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:
  UserDir public_html


  <Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI
      Order allow,deny
      Allow from all
      Order deny,allow
      Deny from all

Configure PHP

PHP is practically available out of the box now.

  • Uncomment this line in /etc/httpd/conf/httpd.conf
  #LoadModule php5_module lib/apache/
  • Restart Apache Server to make changes take effect (as root):
  # /etc/rc.d/httpd restart
  • Test PHP with a simple, but very informational script:
  <title>PHP Test Page</title>

  This is Arch Linux, running PHP.


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:
 http://localhost/test.php or http://localhost/~myname/test.php

Configure PostgreSQL

Do these only if you want PostgreSQL support

  • Edit /etc/php.ini (this is in /usr/etc on older systems) to uncomment the following line:

work in progress