Install Mod Vhost Alias Ubuntu
Fastcgi has many improvements over the traditional cgi model of executing external programs inside a webserver. With fastcgi multiple processes are kept alive and each process is reused to serve multiple requests one after another. There are settings to control the maximum number of requests a process can serve, after which the process is terminated and a new one is started. Install the packages The first thing to do is install the necessary packages from synaptic. We need to install the apache server, modfastcgi, mpm worker and php along with the cgi binary. Note that if you already have php installed with mpm prefork and mod-php then it would be removed upon installing these packages $ sudo apt-get install apache2 libapache2-mod-fastcgi apache2-mpm-worker php5 php5-cgi On ubuntu the apache configuration file located at /etc/apache2/sites-enabled/000-default The php cgi binary is located at /usr/bin/php-cgi. Configure fastcgi After installing the packages, its time to configure apache to use modfastcgi to run php scripts.
I've just setup apache/php/mysql in Ubuntu 12.04, and I've created an Alias for my. Apache2 Alias not working in Ubuntu? Be solved by the mod_alias. HTTPD - Apache2 Web Server. The Apache2 web server is available in Ubuntu Linux. To install Apache2. Sudo apt install libapache2-mod-auth-mysql. Set up Apache virtual hosts on Ubuntu. 80 Listen 80 mod_ssl.c> # SSL. Enabled vhost files in alphabetical order and.
Like cgi, fastcgi will also run php processes using the php-cgi binary. First enable the fastcgi module with a2enmod command $ sudo a2enmod fastcgi The a2enmod command copies the configuration file of the module from /etc/apache2/mods-available to the directory /etc/apache2/mods-enabled.
The configuration file in this case is fastcgi.conf. It looks like this AddHandler fastcgi-script.fcgi FastCgiIpcDir /var/lib/apache2/fastcgi Modfastcgi registers a handler called fastcgi-script with apache. This can be used to specify which programs to execute through modfastcgi.
Ok, lets move on. Next thing is to configure the relevant vhost to run php using the fastcgi handler. Put the following configuration inside the desired vhost block in the apache configuration file. FastCgiServer /usr/local/bin/php-fastcgi-wrapper -processes 10 -restart-delay 1 -init-start-delay 1 -pass-header HTTPAUTHORIZATION Alias /binary /usr/local/bin Options ExecCGI SetHandler fastcgi-script AddHandler php-fastcgi.php Action php-fastcgi /binary/php-fastcgi-wrapper The FastCgiServer registers /usr/local/bin/php-fastcgi-wrapper as the fastcgi application with various options. Note that this is a shell script that will launch the php-cgi binary with various settings. Note that we asked the FastCgiServer to create and manage 10 processes.
The AddHandler line declares a new handler for '.php' files called php-fastcgi. This can named to anything you like. The Action line tells apache to handle php-fastcgi file using the cgi program /cgi-bin/php-fastcgi-wrapper. Now the location /cgi-bin/php-fastcgi-wrapper is not a real one.
To make it point to the real location of wrapper script, the Alias directive is used. It points /cgi-bin to /usr/local/bin. Wrapper script Now comes the wrapper script that will be used by fastcgi to run php. #!/bin/sh # Set desired PHPFCGI. environment variables. # Example: # PHP FastCGI processes exit after 500 requests by default. PHPFCGIMAXREQUESTS=10000 export PHPFCGIMAXREQUESTS PHPFCGICHILDREN=5 export PHPFCGICHILDREN # Replace with the path to your FastCGI-enabled PHP executable exec /usr/bin/php-cgi Note the PHPFCGICHILDREN setting.
It specifies that each php process should further fork and manage 5 more child php processes. So earlier fastcgi was told to create 10 processes. The total is 10.5 = 50 processes. There are 2 levels of process management going on. Modfastcgi manages 10 php processes and each php process further manages 5 process each. This file is stored at the following path /usr/local/bin/php-fastcgi-wrapper Make sure that the file is executable.
Do a chmod on it /usr/local/bin# chmod +x php-fastcgi-wrapper The location of the file does not matter. The wrapper script is necessary so that various options like PHPFCGIMAXREQUESTS can be passed on to the php process. Now restart apache and test the setup by opening a php script in browser. View the contents of the $SERVER variable in php. It should contain FCGIROLE = RESPONDER.
This indicates that fastcgi is in action. Also check the process table using htop or System Monitor. You should see 50 php-cgi processes running. 4 thoughts on “ Install and configure Apache and php with mod fastcgi on Ubuntu/Debian”.
tylercollier My previous comment about “client denied by server configuration: /usr/local/bin/php-fastcgi-wrapper” has not yet been approved, so I can’t see, edit, or reply to it. But I wanted to post my fix. Add Directory /usr/local/bin Require all granted /Directory to your vhost config.
Give More Feedback
EDIT: I guess I can’t use markdown here and Disqus is munging my “html” of the directory element, so I replaced angle brackets with brackets.
This guide explains how you can use modmysqlvhost to create simple virtual hosts on a lighttpd web server on Ubuntu 12.10. With modmysqlvhost, lighttpd can read the vhost configuration from a MySQL database.
Currently, you can store the domain and the document root in the MySQL database which results in very simple virtual hosts. Gear 2 ebay. If you need more directives for your vhosts, you’d have to configure them in the global section of lighttpd.conf, which means they’d be valid for all vhosts. Therefore, modmysqlvhost is ideal if your vhosts differ only in the domain and document root. I do not issue any guarantee that this will work for you! 1 Preliminary Note Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing sudo su 2 Installing MySQL 5 First we install MySQL 5 like this: apt-get install mysql-server mysql-client You will be asked to provide a password for the MySQL root user – this password is valid for the user root@localhost as well as root@server1.example.com, so we don’t have to specify a MySQL root password manually later on: New password for the MySQL “root” user.