Install Apache2 in Ubuntu
After installation
Type the server’s IP address (or alias if you added the server to your /etc/hosts file) in your browser’s address bar or, if you are browsing on the server itself, type 127.0.0.1 or localhost. If an error occurs, then you will have to edit the apache2.conf file to ensure that Apache can fully resolve the server’s name.If you have any problem then you have to edit the apache2 configuration file using the following command
sudo nano /etc/apache2/apache2.conf
Add the following line somewhere
ServerName localhost
or
ServerName yourserverip
Save and exit the file
Restart Apache server using the following command.
sudo apache2ctl restart
Change default document root in Apache2
The main configuration file located at /etc/apache2/apche2.conf.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 where ever you want to change.For example if you want to change /home/www the above line looks like this “DocumentRoot /home/www/”.
Save and exit the file
Restart Apache server using the following command.
sudo apache2ctl restart
Enable CGI and perl support for apache2 server
You need to install the following package
You need to create a cgi-bin directory using the following command
sudo mkdir /home/www/cgi-bin
Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs and add the following to the site configuration file (again between the <VirtualHost> tags).
**AddHandler default-handler .jpg .png .gif .js .txt .bat .css .html .htm
this tells cgi to exclude some of the non perl related files like "CSS,txt,html etc"
Test your Perl Program
cd /home/www/cgi-bin
sudo nano perltest.pl
Copy and paste the following section save and exit the file.
sudo chmod a+x perltest.pl
Open your web browser open
http://yourserverip/cgi-bin/perltest.pl.It should be working.
Enable PHP support for apache2 webserver
If you want to enable php5 or php4 support to your apache webserver use the following commands to install require packages
For PHP5
sudo a2enmod php5
sudo a2enmod php4
After installing php support you need to restart apache webserver using the following command
sudo apache2ctl restart
Test your PHP Support foe apache webserver
To check the status of your PHP installation
sudo nano /var/www/testphp.php
and insert the following line
Now open web browser at http://yourserveripaddress/testphp.php and check.
Removing Apache2:
cmd:
sudo aptitude install apache2This will complete the installation.
After installation
Type the server’s IP address (or alias if you added the server to your /etc/hosts file) in your browser’s address bar or, if you are browsing on the server itself, type 127.0.0.1 or localhost. If an error occurs, then you will have to edit the apache2.conf file to ensure that Apache can fully resolve the server’s name.If you have any problem then you have to edit the apache2 configuration file using the following command
sudo nano /etc/apache2/apache2.conf
Add the following line somewhere
ServerName localhost
or
ServerName yourserverip
Save and exit the file
Restart Apache server using the following command.
sudo apache2ctl restart
Change default document root in Apache2
The main configuration file located at /etc/apache2/apche2.conf.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 where ever you want to change.For example if you want to change /home/www the above line looks like this “DocumentRoot /home/www/”.
Save and exit the file
Restart Apache server using the following command.
sudo apache2ctl restart
Enable CGI and perl support for apache2 server
You need to install the following package
sudo aptitude install libapache2-mod-perl2Configure a cgi-bin directory
You need to create a cgi-bin directory using the following command
sudo mkdir /home/www/cgi-bin
Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs and add the following to the site configuration file (again between the <VirtualHost> tags).
AddHandler default-handler .jpg .png .gif .js .txt .bat .css .html .htmScriptAlias /cgi-bin/ /home/www/cgi-bin/
<Directory /home/www/cgi-bin/>
Options ExecCGI
AddHandler cgi-script cgi pl
</Directory>
The first line creates an alias that points to the directory in which
CGI scripts are stored. The final line tells Apache that only files
that end with the *.cgi and *.pl extensions should be considered CGI
programs and executed.**AddHandler default-handler .jpg .png .gif .js .txt .bat .css .html .htm
this tells cgi to exclude some of the non perl related files like "CSS,txt,html etc"
Test your Perl Program
cd /home/www/cgi-bin
sudo nano perltest.pl
Copy and paste the following section save and exit the file.
Change permissions on it###Start###
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
sudo chmod a+x perltest.pl
Open your web browser open
http://yourserverip/cgi-bin/perltest.pl.It should be working.
Enable PHP support for apache2 webserver
If you want to enable php5 or php4 support to your apache webserver use the following commands to install require packages
For PHP5
sudo aptitiude install php5 libapache2-mod-php5For PHP4
sudo aptitiude install php4 libapache2-mod-php4You also make sure the php5 and php4 modules are enabled using the following commands
sudo a2enmod php5
sudo a2enmod php4
After installing php support you need to restart apache webserver using the following command
sudo apache2ctl restart
Test your PHP Support foe apache webserver
To check the status of your PHP installation
sudo nano /var/www/testphp.php
and insert the following line
<?php phpinfo(); ?>
Save and exit the fileNow open web browser at http://yourserveripaddress/testphp.php and check.
Removing Apache2:
cmd:
apt-get remove apache2
No comments:
Post a Comment