Configuring Apache Web Server (Debian/Ubuntu)
Posted by stringofthoughts on May 7, 2009
Please refer to my other post on installing web server on debian/ubuntu
Before we start, you need to know about the files and directories involved
/etc/apache2 :: Server’s root directory
/etc/apache2/sites-available :: Keeps the configurations files for the hosted sites
/etc/apache2/sites-enabled :: Keeps soft links of hosted sites.
/etc/apache2/ports.conf :: Server port and nameserver config file
/etc/apache2/apache2.conf :: Server’s main configuration file
Let’s assume our user name is saumya. The document root for apache by default is /var/www/. You need to change this.
$ mkdir ~/public_html
This will create a directory for user saumya (/home/saumya/public_html). This is the root directory for her website. We need to change the default document root.
$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/saumya
Edit the new configuration file saumya.
$ sudo gedit /etc/apache2/sites-available/saumya
In the file replace /var/www/ with /home/saumya/public_html . Now enable the new site configuration.
$ sudo a2dissite default // disables the default configuration.
$ sudo a2ensite saumya // Enables the new configuration
Restart the server.
$ sudo /etc/init.d/apache2 restart
Make a file index.html in /home/saumya/public_html/ and you are done setting up documet root for your website.To test the file open index.html and write a basic html code
<html>
Linux is awesome.
</html>
save it and open web browser and type http://localhost . If it shows up in the browser everything is working fine.
Assigning IP to server.
By default the server is accessed at 127.0.0.1 or localhost. To assign the IP to server we need to update ports.conf. open the file
$ sudo gedit /etc/apache2/ports.conf
and add a line
Listen
172.20.30.40:80 // Replace 172.20.30.40 with your server IP
Restart the server and it’s all done. Now you can access your website with your IP.
Setting up cgi-bin
Setting up cgi-bin is very easy. Make a directory cgi-bin in document root.
$ mkdir ~/public_html/cgi-bin
Open your the configuration file sites-available folder. In our case it’s saumya.
$ sudo gedit /etc/apache2/sites-available/saumya
and add these lines in between <Virtualhost > tags.
ScriptAlias /cgi-bin/ /home/sam/public_html/cgi-bin/
<Directory /home/sam/public_html/cgi-bin/>
Options ExecCGI
AddHandler cgi-script cgi pl
</Directory>
Well Now you ‘ve configured your website completely. This configuration is good for hosting you website on LAN like university campus. If you really want to host your website on Internet you need to learn a lot about securing apache. Let’s leave that for some other day.
Installing Web Server in Debian/Ubuntu « Just a thought said
[…] Comments Configuring Apache W… on Installing Web Server in …Installing Web Serve… on Tasksel (Bundled software […]