Apache HTTP Server is a free software/open source web server for Unix-like systems, Microsoft Windows, Novell NetWare and other platforms. Apache is notable for playing a key role in the initial growth of the World Wide Web,and continues to be the most popular web server in use, serving as the de facto reference platform against which other web serversare designed and judged.
Apache features configurable error messages, DBMS-based authentication databases, and content negotiation. It is also supported by several graphical user interfaces (GUIs) which permit easier, more intuitive configuration of the server.
Install apache2 in Ubuntu server
sudo apt-get install apache2 apache2-common apache2-mpm-prefork apache2-utils ssl-cert
This will complete the installation of apache2 web server and now you need to know where the configuration files and document root for your apache web server.
By default all your configuration files are located at /etc/apache2
Default document root for apache2 is /var/www.If you want to change the default document root you need to edit the /etc/apache2/sites-available/default file and look for this line “DocumentRoot /var/www/” here you can change whereever you want to change.For example if you want to change /home/wwww the above line looks like this “DocumentRoot/home/www/”.
The main configuration file located at /etc/apache2/apche2.conf.
Bydefault Apache2 to Listen on port 80. If this is not desired, please edit /etc/apache2/ports.conf and /etc/apache2/sites-available as desired.after changing you need restart apache server.
For example if you want to change your apache webserver port to 78 you need to edit /etc/apache2/ports.conf
sudo gedit /etc/apache2/ports.conf
Look for the following line
Listen 80
Replace with the following line
Listen 78
Save the edited file
sudo /etc/init.d/apache2 restart
Installing php and cgi support for apache2 in Ubuntu
you need to have universe source list in your sources.list file
sudo apt-get install libapache2-mod-php4 php4-cli php4-common php4-cgi
Next we edit /etc/apache2/apache2.conf file and check the index files are correct
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
If you want to enable some Apache modules (SSL, rewrite, suexec, and include)
sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod suexec
sudo a2enmod include
Restart Apache to make sure all is well.
sudo /etc/init.d/apache2 restart
Test your apache Server
You can access you apache using http://yourserverip/apache2-default/ it should appear the following screen
Test apache with PHP
To test if php4 installed correctly
sudo gedit /var/www/test.php
Insert the following line into the new file
Save this file
Now access this page http://yourserverip/test.php you should see the following screen
my last default and ports.conf files are like;
default
ServerAdmin webmaster@localhost
DocumentRoot /home/gurhan/www/
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ “/usr/share/doc/”
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
———————————————————————————————————————————————————————————–
ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
#/etc/apache2/sites-enabled/000-default
NameVirtualHost 192.168.1.10:78
Listen 78
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443