Apache2 Web Server
Total Page:16
File Type:pdf, Size:1020Kb
« Alien – Convert RPM to DEB or DEB to RPM Linux and Ubuntu Counter – Register your Linux and your Ubuntu » Apache2 Web server January 24, 2008 by taufanlubis What is Web Server? Before we go to that question, it’s better if we know what is web. Actually, web is only a file or document in HTML format which is transferred from 1 computer (server) to a computer (client) which requests that file/document. To read a web document you need a web client application. There are so many web client applications available, such as Mozilla, Firefox, Opera etc. Did you get a picture what is the Web Server? Yes, Web Server is an application in a computer that supplies files or document which are requested by client computer. There are few web server available in market, such as Apache, IIS and Cold Fusion, but the most popular web server in the world is Apache. Because, almost 70% web servers in the world use Apache. Apache is under GPL. So, you can use it for free. Apache2 or Apache Web Server a default web server installed in Ubuntu. Note: If you are using Gutsy, you don’t have to do the installation. You have it already. You just need to configure the setting only. If you want to use PHP4, you can’t use apache2, it’s designed to work with PHP5 now. You can use Xampp. With Xampp, even you can choose which PHP version that you want to use, PHP4 or PHP5, without change any configuration. Step 1. Apache Installation To install Apache2 in Ubuntu, just type the command below in your Terminal Console. taufanlubis@zyrex:~$ sudo apt-get install apache2 apache2-common apache2-mpm- prefork apache2-utils ………. ………. This command will complete the installation of apache2 web server. Step 2. Apache Configuration The default of apache2 configuration files are located at /etc/apache2. taufanlubis@zyrex:~$ ls -l /etc/apache2/ total 60 -rw-r–r– 1 root root 24175 2007-01-16 01:10 apache2.conf drwxr-xr-x 2 root root 4096 2007-08-03 14:01 conf.d -rw-r–r– 1 root root 895 2007-01-16 01:11 envvars -rw-r–r– 1 root root 0 2007-08-03 14:01 httpd.conf drwxr-xr-x 2 root root 12288 2007-09-07 08:00 mods-available drwxr-xr-x 2 root root 4096 2007-10-03 22:26 mods-enabled -rw-r–r– 1 root root 10 2007-08-03 14:01 ports.conf drwxr-xr-x 2 root root 4096 2007-09-07 08:00 sites-available drwxr-xr-x 2 root root 4096 2007-08-03 14:01 sites-enabled taufanlubis@zyrex:~$ Step 2A. Apache Configuration —sites-available To change it, just edit ‘default‘ file at /etc/apache2/sites-available taufanlubis@zyrex:/$ cd /etc/apache2/sites-available/ taufanlubis@zyrex:/etc/apache2/sites-available$ ls default taufanlubis@zyrex:/etc/apache2/sites-available$ sudo gedit default NameVirtualHost * <VirtualHost *> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2′s default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory “/usr/lib/cgi-bin”> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> 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 ServerSignature On Alias /doc/ “/usr/share/doc/” <Directory “/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 </Directory> </VirtualHost> Step 2B. Apache Configuration —document root If you want to change from ‘/var/www‘ to ‘/home/www‘, just change the ‘DocumentRoot /var/www‘ to be ‘DocumentRoot /home/www‘. The main configuration file is located at /etc/apache2/apache2.conf. ….. ServerRoot “/etc/apache2″ PidFile /var/run/apache2.pid ErrorLog /var/log/apache2/error.log Include /etc/apache2/ports.conf Additional Apache Configuration —Enable some Apache modules (Note: If need it!!!!) SSL, rewrite, suexec and include As you can see above, Apache2 supports a lot of modules and uses DSO (Dynamic Shared Object). DSO will make each module easier to be developed and maintained. Additional Apache Configuration —Add new Modules to Apache2 taufanlubis@zyrex:~$ sudo a2enmod ssl Module ssl installed; run /etc/init.d/apache2 force-reload to enable. taufanlubis@zyrex:~$ sudo a2enmod rewrite Module rewrite installed; run /etc/init.d/apache2 force-reload to enable. taufanlubis@zyrex:~$ sudo a2enmod suexec Module suexec installed; run /etc/init.d/apache2 force-reload to enable. taufanlubis@zyrex:~$ sudo a2enmod include Module include installed; run /etc/init.d/apache2 force-reload to enable. taufanlubis@zyrex:~$ Additional Apache Configuration —Check Apache2 modules installed taufanlubis@zyrex:~$ /usr/sbin/apache2 -l Compiled in modules: core.c mod_log_config.c mod_logio.c prefork.c http_core.c mod_so.c taufanlubis@zyrex:~$ Install PHP5 PHP4 is no longer supported in Feisty. If you still want to use PHP4, I suggest you to use XAMPP. taufanlubis@zyrex:~$ sudo apt-get install php5 Password: Reading package lists… Done Building dependency tree Reading state information… Done The following extra packages will be installed: libapache2-mod-php5 Suggested packages: php-pear The following NEW packages will be installed: libapache2-mod-php5 php5 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 2531kB/2532kB of archives. After unpacking 5743kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://security.ubuntu.com feisty-security/main libapache2-mod-php5 5.2.1- 0ubuntu1.4 [2531kB] Fetched 2531kB in 25s (100kB/s) Selecting previously deselected package libapache2-mod-php5. (Reading database … 156650 files and directories currently installed.) Unpacking libapache2-mod-php5 (from …/libapache2-mod-php5_5.2.1- 0ubuntu1.4_i386.deb) … Selecting previously deselected package php5. Unpacking php5 (from …/php5_5.2.1-0ubuntu1.4_all.deb) … Setting up libapache2-mod-php5 (5.2.1-0ubuntu1.4) … Setting up php5 (5.2.1-0ubuntu1.4) … taufanlubis@zyrex:~$ Install PHP5 Library taufanlubis@zyrex:~$ sudo apt-get install libapache2-mod-php5 Reading package lists… Done Building dependency tree Reading state information… Done libapache2-mod-php5 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. taufanlubis@zyrex:~$ Install MySql for PHP5 taufanlubis@zyrex:~$ sudo apt-get install php5-mysql Reading package lists… Done Building dependency tree Reading state information… Done The following NEW packages will be installed: php5-mysql 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 65.5kB of archives. After unpacking 246kB of additional disk space will be used. Get:1 http://security.ubuntu.com feisty-security/main php5-mysql 5.2.1-0ubuntu1.4 [65.5kB] Fetched 65.5kB in 2s (27.7kB/s) Selecting previously deselected package php5-mysql. (Reading database … 156650 files and directories currently installed.) Unpacking php5-mysql (from …/php5-mysql_5.2.1-0ubuntu1.4_i386.deb) … Setting up php5-mysql (5.2.1-0ubuntu1.4) … taufanlubis@zyrex:~$ Install phpmyadmin for php5-mysql taufanlubis@zyrex:~$ sudo apt-get install phpmyadmin Reading package lists… Done Building dependency tree Reading state information… Done Suggested packages: mysql-server Recommended packages: php5-mcrypt php4-mcrypt php5-gd php4-gd The following NEW packages will be installed: phpmyadmin 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 3591kB of archives. After unpacking 14.1MB of additional disk space will be used. Get:1 http://archive.ubuntu.com feisty/universe phpmyadmin 4:2.9.1.1-2ubuntu1 [3591kB] Fetched 3591kB in 49s (73.2kB/s) Preconfiguring packages … Selecting previously deselected package phpmyadmin. (Reading database … 156654 files and directories currently installed.) Unpacking phpmyadmin (from …/phpmyadmin_4%3a2.9.1.1-2ubuntu1_all.deb) … Setting up phpmyadmin (2.9.1.1-2ubuntu1) … Creating config file /etc/phpmyadmin/apache.conf with new version Creating config file /etc/phpmyadmin/config.footer.inc.php with new version Creating config file /etc/phpmyadmin/config.header.inc.php with new version Creating config file /etc/phpmyadmin/config.inc.php with new version Creating config file /etc/phpmyadmin/htaccess with new version taufanlubis@zyrex:~$ Check your apache2 modules installed. taufanlubis@zyrex:~$ sudo apt-cache search apache2 (may different with yours) libapache2-mod-auth-mysql – Apache 2 module for MySQL authentication libapache2-mod-auth-pam – module for Apache2 which authenticate using PAM libapache2-mod-auth-pgsql – Module for Apache2 which provides pgsql authentication libapache2-mod-auth-plain – Module for Apache2 which provides plaintext authentication libapache2-mod-auth-sys-group – Module for Apache2 which checks user against system group libapache2-mod-macro – Create macros inside apache2 config files libapache2-mod-python – Apache 2 module that embeds Python within the server libapache2-mod-python-doc – Apache 2 module that embeds Python within the server libapache2-svn – Subversion server modules for Apache adzapper – proxy advertisement zapper add-on libapache-mod-dav – A DAV module for Apache libapache-mod-jk-doc – Documentation of libapache-mod-jk/libapache2-mod-jk packages libapache-ruby1.8 – Ruby libraries for mod_ruby libapache2-mod-annodex