Results 1 to 1 of 1

Thread: php5+apache2-mpm-worker

  1. #1
    Join Date
    Aug 2006
    Beans
    112

    php5+apache2-mpm-worker

    The article Installing Apache2 and PHP5 using mod_fcgid shows how to run php5 with apache2-mpm-worker. The advanage of apache2-mpm-worker over apache2-mpm-prefork is better performance.

    1. Install apache2-mpm-worker and the fastcgi apache module libapache-mod-fcid
    Code:
    #apt-get install apache2-mpm-worker  libapache2-mod-fcgid
    2. Enable the Fastcgi apache module mod_fcgid
    Code:
    #sudo a2enmod fcgid
    3. Install php5-cgi and the command-line version php5-cli

    Code:
    #sudo aptitude install php5-cgi php5-cli
    4. Add the following to /etc/apache2/httpd.conf or create a file in /etc/apache2/conf.d called, say, /etc/apache2/conf.d/00-myconf

    Code:
    <Directory /var/www>
    AddHandler fcgid-script .php
    FCGIWrapper /usr/lib/cgi-bin/php5 .php
    
    # The line below is optional. You can add the ExecCGI option to each
    # <Directory /var/www/some-path></Directory> block instead.
    
    Options +ExecCGI
    </Directory>
    This is also a good place to add any Aliases you have
    Code:
    Alias /aptitude        /usr/share/doc/aptitude/html/en
    Alias /apt             /usr/share/doc/apt-doc
    Alias /phpgedview      /usr/share/phpgedview
    
    <Directory /usr/share>
    AddHandler fcgid-script .php
    FCGIWrapper /usr/lib/cgi-bin/php5 .php
    Options ExecCGI FollowSymlinks Indexes 
    </Directory>
    5. Then, for each virtual host configuration file you have in /etc/apache2/sites-available, add ExecCGI within a <Directoy /path-to-site> block (placed within your <VirtualHost> block). For example,

    #cat /etc/apache2/sites-availabe/yourdomain.com

    Code:
    <VirtualHost *:80>
    ServerAdmin youremail@yourdomain.com
    ServerName yoursite.tld
    ServerAlias www.yourdomain.tld *.yourdomain.tld
    
    DocumentRoot /var/www/yourdomain.com
    
    ErrorLog        /var/log/apache2/yourdomain.tld-error.log
    CustomLog       /var/log/apache2/yourdomain.tld-access.log combined
    
    <Directory /var/www/yourdomain.com>
    Options +ExecCGI 
    
    AllowOverride All
    Order Allow,Deny
    allow from all
    </Directory>
    LogLevel warn
    ServerSignature On
    </VirtualHost>
    Note: The ExecCGI was turned on in /etc/apache2/sites-available/default for /var/www and its subdirectories, so it is not strictly necessary within the <VirtualHost > block shown here. Using + adds fastcgi support (for php) to the options in force. Options don't merge with prior options (they replace them) unless + is used. You can specify entirely different Options, but you must include ExecCGI, if you want php support for your virtual host.

    6. Enable your virtual host

    Code:
    #sudo a2ensite yourdomain.com
    7. And reload the apache configuration

    Code:
    #sudo /etc/init.d/apache2 force-reload
    or just restart apache2

    Code:
    #sudo /etc/init.d/apache2 restart
    A similar technique is shown in this article from Digital Nerds
    Last edited by kkruecke; January 13th, 2009 at 01:32 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •