如何让PHP在Apache2 MPM Worker上运行?

我正在虚拟远程服务器上设置apache和php。

我想用MPM Worker而不是Prefork,因为我在上个月遇到了prefork的内存使用问题,并且因为我确实读到了这个worker比prefork快。

但是我有麻烦让PHP运行。

我遵循这个指示: http://www.garron.me/blog/ubuntu-lamp-apache2-mpm-worker-and-php-fpm.html但是当我打电话的http://www.mydomain.xy/test。 PHP我得到这个错误:

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

我必须改变以避免这个错误?

这是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" 

这是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 

我把这个文件添加到/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> 

在网站启用我有softlinks这个文件:

 #000-default.conf <VirtualHost *:80> ServerName xxxx: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> 

和这个文件:

 #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> 

你需要额外的信息吗?

我必须改变以避免这个错误?

你可能必须configuration允许所有的目录

类似的东西。 请在应用这个之前仔细检查权限,因为这可能会打开cgi文件夹太多。

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