Arch 2007.08 - Apache and PHP Install
Apache is one of the most popular applications used to serve web pages. This article will show you how to set it up with PHP. This article assumes that you have followed the Arch 2007.08 - Setup article.
Install Apache and PHP
We'll be using pacman to install Apache and PHP, so let's sync our packages first.
sudo pacman -Sy
Once we've done this, let's install our packages.
sudo pacman -S apache php
Easy enough, yes?
Now we have it installed, let's do some basic configuring.
sudo vi /etc/httpd/conf/httpd.conf
Apache, by default, listens on port 80, as seen by:
If we're not running an SSL site, this will be fine. If you are, you'll need to also put a listen statement for port 443:
Listen 80 Listen 443
User and Group
This controls what user and group that Apache accesses the filesystem as. The default is as follows:
User http Group http
This will be fine for now.
The default isn't a valid email address:
Change this to your preferred contact email address:
Apache tries to automatically determine the server, but let's set it up with our hostname. The default is:
We need to change this to our domain, and remove the comment hash.
Nothing needs to be changed here, but do note that your default web root is /srv/http/, which can differ from other Linux distros which put your web root at /var/www/.
Bu default, Apache on Arch allows directory listings for directories that don't contain an index file. Let's go ahead and turn that off so people and search engines can't browse our directories. Find the following part of the file:
... <Directory "/srv/http/"> ...
After some commented lines, you'll see:
Options Indexes FollowSymLinks
Go ahead and remove Indexes so that the line looks like this:
The other settings can be left at the default for now, but go ahead and read over the rest of the file to familiarize yourself with it.
Turning it on
Now that we're all configured and secured, let's fire it up.
sudo /etc/rc.d/httpd start
If you navigate to your IP address, you should see a 403 Forbidden Warning now. This is good -- this means that Apache is working properly and your directory indexes aren't showing. Since you don't have an index.html file in /srv/http/, it gives a permission error.
Keeping it on
Now that it's up and running, let's make it so that Apache will come back on after a reboot of the server.
sudo vi /etc/rc.conf
Find the line that references daemons...
... DAEMONS=(syslog-ng iptables network netfs crond sshd) ...
...and add httpd at the end of it. The finished line should look like:
... DAEMONS=(syslog-ng iptables network netfs crond sshd httpd) ...
Save and exit.
© 2014 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER