Apache2 Installation in Debian
By Default apache2 package you will be given the package apache2-mpm-worker, other packages are available:
apache2-mpm-worker
The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.
apache2-mpm-prefork
This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.
#apt-get install apache2
#apt-get install apache2-mpm-prefork
That's it basic apache2 installation finished.If you want to test your installation go to your browser and type the following
http://youripaddress/apache2-default/
This should display welcome message then your installation is correct.
Default document root directory for apache2 is /var/www
If you want to change the default document root directory in apache2 you have to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.
Now you need to install PHP4 and PHP5 modules for apache2
If you want to run PHP5 and PHP4 supprt at the same time it is not possible, we must run one of them as CGI, the other one as Apache module. We will use PHP5 as Apache module and PHP4 as CGI.
If you want to install PHP5 from debian packages you need to enter the one of the source list in your /etc/apt/sources.list file
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
Now you need to run the following command to update source list
#apt-get update
Now you need to install following modules to support PHP5 and PHP4
#apt-get install libapache2-mod-php5 php4-cgi php5-curl php5-dev php5-gd php5-gmp php5-imap php5-ldap php5-mcrypt php5-mhash php5-ming php5-pspell php5-snmp php5-sybase php5-tidy php4-curl php4-domxml php4-gd php4-gmp php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-ming php4-mysql php4-odbc php4-pspell php4-recode php4-snmp php4-xslt php4-xdebug curl libwww-perl imagemagick
Now you need to change the following line from /etc/apache2/apache2.conf file
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
to
DirectoryIndex index.html index.htm index.shtml index.cgi index.pl index.php index.php4 index.xhtml
and add these two lines in the section where you can find AddType and AddHandler directives
AddHandler php-script .php4
Action php-script /cgi-bin/php4
This will make sure that PHP files with the extension .php4 are executed as CGI. PHP files with the extension .php will be run by the Apache2-PHP5 module.
Next, we have to enable a few Apache modules, like for example the actions module otherwise we cannot run PHP4 as CGI
#a2enmod actions ssl rewrite suexec include
Now you need to restart your apache server using the following command
#/etc/init.d/apache2 restart
Wednesday, March 21, 2007
Configure Per-user web directories in Apache
This type of configuration is useful for ISP's where they will provide their customers free web space.
On systems with multiple users, each user can be permitted to have a web site in their home directory using the UserDir directive. Visitors to a URL http://example.com/~username/ will get content out of the home directory of the user "username", out of the subdirectory specified by the UserDir directive.
Setting the file path with UserDir
The UserDir directive specifies a directory out of which per-user content is loaded. This directive may take several different forms.
If a path is given which does not start with a leading slash, it is assumed to be a directory path relative to the home directory of the specified user. Given this configuration:
UserDir public_html
the URL http://example.com/~debian/index.html will be translated to the file path /home/debian/public_html/index.html
If a path is given starting with a slash, a directory path will be constructed using that path, plus the username specified. Given this configuration:
UserDir /var/html
the URL http://example.com/~debian/index.html will be translated to the file path /var/html/debian/index.html
If a path is provided which contains an asterisk (*), a path is used in which the asterisk is replaced with the username. Given this configuration:
UserDir /var/www/*/htdocs
the URL http://example.com/~debian/index.html will be translated to the file path /var/www/debian/htdocs/index.html
Restricting users for limited access
you can restrict what users are permitted to use this functionality:
UserDir enabled
UserDir disabled root ruchi tej
The configuration above will enable the feature for all users except for those listed in the disabled statement. You can, likewise, disable the feature for all but a few users by using a configuration like the following:
UserDir disabled
UserDir enabled debian test
Enabling a cgi directory for each user
In order to give each user their own cgi-bin directory, you can use a directive to make a particular subdirectory of a user's home directory cgi-enabled.
Options ExecCGI
SetHandler cgi-script
Then, presuming that UserDir is set to public_html, a cgi program example.cgi could be loaded from that directory as:
http://example.com/~debian/cgi-bin/example.cgi
Allowing users to alter configuration
If you want to allows users to modify the server configuration in their web space, they will need to use .htaccess files to make these changed. Ensure that you have set AllowOverride to a value sufficient for the directives that you want to permit the users to modify.
On systems with multiple users, each user can be permitted to have a web site in their home directory using the UserDir directive. Visitors to a URL http://example.com/~username/ will get content out of the home directory of the user "username", out of the subdirectory specified by the UserDir directive.
Setting the file path with UserDir
The UserDir directive specifies a directory out of which per-user content is loaded. This directive may take several different forms.
If a path is given which does not start with a leading slash, it is assumed to be a directory path relative to the home directory of the specified user. Given this configuration:
UserDir public_html
the URL http://example.com/~debian/index.html will be translated to the file path /home/debian/public_html/index.html
If a path is given starting with a slash, a directory path will be constructed using that path, plus the username specified. Given this configuration:
UserDir /var/html
the URL http://example.com/~debian/index.html will be translated to the file path /var/html/debian/index.html
If a path is provided which contains an asterisk (*), a path is used in which the asterisk is replaced with the username. Given this configuration:
UserDir /var/www/*/htdocs
the URL http://example.com/~debian/index.html will be translated to the file path /var/www/debian/htdocs/index.html
Restricting users for limited access
you can restrict what users are permitted to use this functionality:
UserDir enabled
UserDir disabled root ruchi tej
The configuration above will enable the feature for all users except for those listed in the disabled statement. You can, likewise, disable the feature for all but a few users by using a configuration like the following:
UserDir disabled
UserDir enabled debian test
Enabling a cgi directory for each user
In order to give each user their own cgi-bin directory, you can use a
Options ExecCGI
SetHandler cgi-script
Then, presuming that UserDir is set to public_html, a cgi program example.cgi could be loaded from that directory as:
http://example.com/~debian/cgi-bin/example.cgi
Allowing users to alter configuration
If you want to allows users to modify the server configuration in their web space, they will need to use .htaccess files to make these changed. Ensure that you have set AllowOverride to a value sufficient for the directives that you want to permit the users to modify.
Installing Apache 2 in Debian 3.1 (Sarge) with PHP5 support
By Default apache2 package you will be given the package apache2-mpm-worker, other packages are available:
apache2-mpm-worker
The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.
apache2-mpm-prefork
This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.
#apt-get install apache2
#apt-get install apache2-mpm-prefork
That's it basic apache2 installation finished.If you want to test your installation go to your browser and type the following
http://youripaddress/apache2-default/
This should display welcome message then your installation is correct.
Default document root directory for apache2 is /var/www
If you want to change the default document root directory in apache2 you have to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.
Install PHP5 support for Apache2
If you want to install PHP5 from debian packages you need to enter the one of the source list in your /etc/apt/sources.list file
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
or
deb http://people.debian.org/~dexter php5 sarge
deb-src http://people.debian.org/~dexter php5 sarge
Now you need to save your file and run the following command to take our new changes effect
#apt-get update
Now you need to install PHP5 required packages for apache
#apt-get install php5 libapache2-mod-php5 php5-curl php5-gd
that's it PHP5 for apache2 installed now you need to do the following
#cd /etc/apache2/mods-enabled/
#ln -s /etc/apache2/mods-available/php5.load
#ln -s /etc/apache2/mods-available/php5.conf
Now you need to restart your apache server using the following command
#/etc/init.d/apache2 restart
Now you apache server is ready with PHP5 support
apache2-mpm-worker
The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.
apache2-mpm-prefork
This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.
#apt-get install apache2
#apt-get install apache2-mpm-prefork
That's it basic apache2 installation finished.If you want to test your installation go to your browser and type the following
http://youripaddress/apache2-default/
This should display welcome message then your installation is correct.
Default document root directory for apache2 is /var/www
If you want to change the default document root directory in apache2 you have to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.
Install PHP5 support for Apache2
If you want to install PHP5 from debian packages you need to enter the one of the source list in your /etc/apt/sources.list file
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
or
deb http://people.debian.org/~dexter php5 sarge
deb-src http://people.debian.org/~dexter php5 sarge
Now you need to save your file and run the following command to take our new changes effect
#apt-get update
Now you need to install PHP5 required packages for apache
#apt-get install php5 libapache2-mod-php5 php5-curl php5-gd
that's it PHP5 for apache2 installed now you need to do the following
#cd /etc/apache2/mods-enabled/
#ln -s /etc/apache2/mods-available/php5.load
#ln -s /etc/apache2/mods-available/php5.conf
Now you need to restart your apache server using the following command
#/etc/init.d/apache2 restart
Now you apache server is ready with PHP5 support
Subscribe to:
Posts (Atom)
