How to get PHP running on Apache2 MPM Worker?

5,835

you probably have to configure the directory for allow all

something like that. please double check the permissions before applying this, as this may open the cgi folder a little too much.

<Directory "/php5-fcgi/">
        Options +Indexes FollowSymLinks +ExecCGI
        AllowOverride AuthConfig FileInfo
                Order allow,deny
        Allow from all
</Directory>
Share:
5,835

Related videos on Youtube

Hubert Schölnast
Author by

Hubert Schölnast

Updated on September 18, 2022

Comments

  • Hubert Schölnast
    Hubert Schölnast over 1 year

    I am setting up apache and php on a virtual remote server.

    I want to use MPM Worker instead of prefork because I had troubles with ram-useage of prefork in the last month and because I did read that worker is performing faster than prefork.

    But I have troubles to get PHP running.

    I followed this instructions: http://www.garron.me/blog/ubuntu-lamp-apache2-mpm-worker-and-php-fpm.html but when i call http://www.mydomain.xy/test.php I get this error:

    You don't have permission to access /php5-fcgi/test.php on this server.
    

    What must i change to avoid this error?

    This is the output of apachectl -V:

    Server version: Apache/2.2.22 (Ubuntu)
    Server built:   Mar  8 2013 15:53:20
    Server's Module Magic Number: 20051115:30
    Server loaded:  APR 1.4.6, APR-Util 1.3.12
    Compiled using: APR 1.4.6, APR-Util 1.3.12
    Architecture:   64-bit
    Server MPM:     Worker
      threaded:     yes (fixed thread count)
        forked:     yes (variable process count)
    Server compiled with....
     -D APACHE_MPM_DIR="server/mpm/worker"
     -D APR_HAS_SENDFILE
     -D APR_HAS_MMAP
     -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
     -D APR_USE_SYSVSEM_SERIALIZE
     -D APR_USE_PTHREAD_SERIALIZE
     -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     -D APR_HAS_OTHER_CHILD
     -D AP_HAVE_RELIABLE_PIPED_LOGS
     -D DYNAMIC_MODULE_LIMIT=128
     -D HTTPD_ROOT="/etc/apache2"
     -D SUEXEC_BIN="/usr/lib/apache2/suexec"
     -D DEFAULT_PIDLOG="/var/run/apache2.pid"
     -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
     -D DEFAULT_ERRORLOG="logs/error_log"
     -D AP_TYPES_CONFIG_FILE="mime.types"
     -D SERVER_CONFIG_FILE="apache2.conf"
    

    This is apache2.conf:

    ServerRoot "/etc/apache2"
    LockFile ${APACHE_LOCK_DIR}/accept.lock
    PidFile ${APACHE_PID_FILE}
    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 10
    
    <IfModule mpm_worker_module>
        StartServers            3
        MinSpareThreads        25
        MaxSpareThreads       100 
        ThreadLimit            64
        ThreadsPerChild        20
        MaxClients            300
        MaxRequestsPerChild 20000
    </IfModule>
    
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    
    AccessFileName .htaccess
    
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
        Satisfy all
    </Files>
    
    DefaultType text/html
    HostnameLookups Off
    
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf
    Include /etc/apache2/httpd.conf
    Include /etc/apache2/ports.conf
    Include /etc/apache2/conf.d/
    Include /etc/apache2/sites-enabled/
    
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    ErrorLog  /var/log/apache2/NoVHost_error.log
    LogLevel  warn
    CustomLog /var/log/apache2/NoVHost_access.log common
    

    I added this file to /etc/apache2/conf.d/: /etc/apache2/conf.d/php.conf

    <IfModule mod_fastcgi.c>
        AddHandler php5-fcgi .php
        Action php5-fcgi /php5-fcgi
        Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
        FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
    </IfModule>
    

    In Sites-enabled i have softlinks to this files:

    #000-default.conf
    <VirtualHost *:80>
        ServerName x.x.xx:80
        DocumentRoot /var/www/default
        ServerAdmin [email protected]
        <Directory />
            Options None
            AllowOverride None
            Order deny,allow
                    Deny from all
            DirectoryIndex index.html
        </Directory>
        <Directory /var/www/default/>
            Order allow,deny
            allow from all
            DirectoryIndex index.html
        </Directory>
        ErrorLog /var/log/apache2/DefaultVHost_error.log
        LogLevel warn
        CustomLog /var/log/apache2/DefaultVHost_access.log common
    </VirtualHost>
    

    and this file:

    #899-www.mydomain.xy
    
    <VirtualHost *:80>
        ServerName www.mydomain.xy:80
        ServerAlias mydomain.xy *.mydomain.xy
        DocumentRoot /var/www/www.mydomain.xy/www
        ScriptAlias /cgi-bin/ /var/www/www.mydomain.xy/cgi-bin/
        ServerAdmin [email protected]
    
        <Directory />
            Options None
            AllowOverride None
            Order deny,allow
            Deny from all
            DirectoryIndex index.html
        </Directory>
    
        <Directory /var/www/www.mydomain.xy/www/>
            Options -ExecCGI +FollowSymLinks -Includes -Indexes -MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
            DirectoryIndex index.html
        </Directory>
    
        <Directory "/var/www/www.mydomain.xy/cgi-bin">
            AllowOverride None
            Options +ExecCGI +FollowSymLinks -Includes -Indexes -MultiViews
            Order allow,deny
            Allow from all
        </Directory>
    
        ErrorLog /var/log/apache2/www_shapp_at_error.log
        LogLevel warn
        CustomLog /var/log/apache2/www_shapp_at_access.log common
    
    </VirtualHost>
    

    Do you need additional infos?

    What must i change to avoid this error?