Fri 6 Mar 2009
Setting up an Apache and PHP webserver
Posted by Kris under Tech
No Comments
This guide assumes that you’ve already got a server running either debian or ubuntu, and you want to make it serve web pages.
First, install apache2, php, and some other useful modules
apt-get install apache2 libapache2-mod-php5 php5-cli php5-curl php5-gd php5-imap php5-common php5-mysql
That’s it, you should now be able to browse to http://localhost and see the default apache page!
By default, the webroot is /var/www/ but if you’re planning to host a domain you’ll probably want to point it somewhere else. This is how you configure apache to listen for the domain www.example.com and set the webroot as /home/www/www.example.com/ (it’s assumed that you’ve already got an A record in the sites DNS pointing to this server)
/etc/init.d apache2 stop
Then create the apache zone file in /etc/apache2/sites-available/www.example.com/ with the following content:
<VirtualHost x.x.x.x:80>
ServerAdmin me@example.com
DocumentRoot /home/www/www.example.com
ServerName www.example.com
ErrorLog /var/log/apache2/error_log
CustomLog /var/log/apache2/access_log combined
EnableSendfile Off
EnableMMap Off
</VirtualHost>
Replacing x.x.x.x with your servers IP address.
Next, you need to enable the site, and start apache.
a2ensite www.example.com
/etc/init.d/apache2 start
That’s it!








No Responses to “ Setting up an Apache and PHP webserver ”