This section describes how to set up a simple web server on an Arch Linux system. The combination of applications we will be installing is commonly referred to as LAMP (Linux Apache MySQL PHP).
# pacman -S apache php mysql
This document assumes you will install Apache, PHP and MySQL together. If desired however, you may install Apache, PHP, and MySQL separately and simply refer to the relevant sections below. Template:Box Note
These options in /etc/httpd/conf/httpd.conf might be interesting for you:
# Listen 80
This is the port Apache will listen to. For Internet-access with router, you have to forward the port.
# ServerAdmin firstname.lastname@example.org
This is the admin's email-address which can be found on error-pages e.g.
# DocumentRoot "/srv/http"
This is the directory where you should put your web pages. Change it, if you want to, but don't forget to change the
to whatever you changed your DocumentRoot to.
PHP is practically available out of the box now.
- Add these line in
LoadModule php5_module modules/libphp5.so Include conf/extra/php5_module.conf
NOTE: The "Include" can not be directly after the "LoadModule" line in the configuration file, it need to be down with the other "Includes".
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so AddHandler php5-script php
- Remember to add a file handler for .phtml if you need it in /etc/httpd/conf/extra/php5_module.conf:
DirectoryIndex index.php index.phtml index.html
- If you want the libGD module, uncomment in
Pay attention to which extension you uncomment, as this extension is sometimes mentioned in an explanatory comment before the actual line you want to uncomment.
- If your
DocumentRootis outside of
/home/, add it to
open_basedir = /home/:/tmp/:/usr/share/pear/:/path/to/documentroot
suggestion - Add your document root as follows: open_basedir = /home/:/tmp/:/usr/share/pear/:/srv/http
- Restart the Apache service to make changes take effect (as root):
# /etc/rc.d/httpd restart
- Test PHP with a simple, but very informative script:
<html> <head> <title>PHP Test Page</title> </head> <body> This is Arch Linux, running PHP. <?php phpinfo(); ?> </body> </html>
Save this file as
test.php and copy to
/srv/http/ or to
~/public_html if you permitted such a configuration.
If you continue to have problems, edit your /etc/httpd/conf/httpd.conf file with the following information
- Edit your httpd.conf file
# nano /etc/httpd/conf/httpd.conf
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
- Restart Apache
# /etc/rc.d/httpd restart
Be sure to test the page again to verify it's working properly (as stated above).
- Configure MySQL as described at the MySQL wiki.
/etc/php/php.ini(this is in
/usr/etcon older systems) to uncomment the following line (By removing
- You can add minor privileged users for your web scripts by editing the tables found in the
mysqldatabase. You have to restart MySQL for changes to take effect. Don't forget to check the
mysql/userstable. If there's a second entry for root and your hostname is left with no password set, everybody from your host probably could gain full access. Perhaps see next section for these jobs.
- Run in terminal (as root):
# /etc/rc.d/mysqld start
- MySQL should now be running. Test by visiting
http://localhost/phpMyAdminin a web browser - for testing by phpMyAdmin, you should have installed phpMyAdmin (
pacman -S phpmyadmin). It should display phpMyAdmin main page.
/etc/rc.conf(to start MySQL at boot):
DAEMONS=(... mysqld ...)
Or add this line to
- You can get the "
error no. 2013: Lost Connection to mysql server during query" message instantly whenever you try to connect to the MySQL daemon by TCP/IP. This is the TCP wrappers system (tcpd), which uses the
hosts_access(5)system to allow or disallow connections.
- If you're running into this problem, be sure to add this to your /etc/hosts.allow file:
# mysqld : ALL : ALLOW # mysqld-max : ALL : ALLOW # and similar for the other MySQL daemons.
- Notes: The examples above are the simplest case, telling tcpd to allow connections from anywhere. You may wish to use a more-appropriate choice of permissible sources instead of ALL. Just make sure that localhost and the IP address (numeric or DNS) of the interface by which you connect are specified.
- You might also need to edit
/etc/my.cnfand comment out the
skip-networkingline as such: