Tuesday, January 1, 2013

Ubuntu 12.10 + Apache + Perl + PHP



 Apache


Install Apache
  • sudo apt-get install apache2
Start Apache
  • sudo /etc/init.d/apache2 start
Stop Apache
  •  sudo /etc/init.d/apache2 stop
Restart Apache
  • sudo /etc/init.d/apache2 restart

Main Configuration File
  • sudo nano /etc/apache2/apache2.conf
Set the Virtual Hosts here;
  • sudo nano /etc/apache2/sites-available/default
Apache Error Log
  • sudo nano /var/log/apache2/error.log
Location of Web Server Files
  • /var/www/ 

 

PHP

Install PHP
  • sudo apt-get install php5 libapache2-mod-php5

PERL 

  • Perl is pre-installed.
  • whereis perl to see the location where perl is installed.
  • perl-v check the version which is in use.
  • Use /usr/lib/cgi-bin to put perl files.
  • Make the changes in BOLD in the Virtual host (/etc/apache2/sites-available/default)
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                AddHandler cgi-script cgi pl
                Order allow,deny
                Allow from all
        </Directory>

  • Change the permission in the perl script to 755 (sudo chmod 755 test.pl)
  • Now run http:localhost/cgi-bin/test.pl

  • Sample perl script test.pl 
        #!/usr/bin/perl -w  -> location of perl  
       print "Content-type: text/html\r\n\r\n";     -> without this line it will give an internal server error 
       print "Hello there";

  • Running Perl in Terminal
                perl filename.pl

No comments:

Post a Comment