IMPORTANT NOTE: If you have an SSL backend or an SSL (HTTPS) and normal HTTP domain simultaneously you’ll need to complete this for both vhosts, otherwise you will not be able to upload media, themes or plugins when logged in.to your wp-admin.
1. Download and install mod_suphp
Get the RPM: http://rpm.centoshelp.org/el6/mod_suphp/
Command: rpm -ivh http://rpm.centoshelp.org/el6/mod_suphp/mod_suphp-0.7.1-1.el6.cosh.x86_64.rpm
2. Contents of /etc/suphp.conf:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[global] logfile=/var/log/httpd/suphp_log loglevel=info webserver_user=apache docroot=/ env_path=/bin:/usr/bin umask=0077 min_uid=500 min_gid=500 ; Security options allow_file_group_writeable=true allow_file_others_writeable=false allow_directory_group_writeable=true allow_directory_others_writeable=false ;Check wheter script is within DOCUMENT_ROOT check_vhost_docroot=true ;Send minor error messages to browser errors_to_browser=true [handlers] ;Handler for php-scripts x-httpd-php="php:/usr/bin/php-cgi" ;Handler for CGI-scripts x-suphp-cgi="execute:!self" |
3. Contents of /etc/httpd/conf.d/suphp.conf :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# This is the Apache server configuration file providing suPHP support. # It contains the configuration directives to instruct the server how to # serve php pages while switching to the user context before rendering. LoadModule suphp_module modules/mod_suphp.so # This option tells mod_suphp if a PHP-script requested on this server (or # VirtualHost) should be run with the PHP-interpreter or returned to the # browser "as it is". suPHP_Engine off # Disable php when suphp is used, to avoid having both. #<IfModule mod_php5.c> #php_admin_flag engine off #</IfModule> #<IfModule mod_php4.c> #php_admin_flag engine off #</IfModule> # To use suPHP to parse PHP-Files #AddHandler x-httpd-php .php #AddHandler x-httpd-php .php .php4 .php3 .phtml # This option tells mod_suphp which path to pass on to the PHP-interpreter # (by setting the PHPRC environment variable). # Do *NOT* refer to a file but to the directory the file resides in. # # E.g.: If you want to use "/path/to/server/config/php.ini", use "suPHP_Config # /path/to/server/config". # # If you don't use this option, PHP will use its compiled in default path. # suPHP_ConfigPath /etc # If you compiled suphp with setid-mode "force" or "paranoid", you can # specify the user- and groupname to run PHP-scripts with. # Example: suPHP_UserGroup foouser bargroup # suPHP_UserGroup apache apache # This option tells mod_suphp to handle requests with the type <mime-type>. # Please note this only works, if an action for the handler is specified # in the suPHP configuration file. # suPHP_AddHandler x-httpd-php # This option tells mod_suphp to NOT handle requests with the type <mime-type>. # suPHP_RemoveHandler <mime-type> |
4. Add the following lines in the < Virtualhost > block of the httpd configuration file(s) for affected Virtualhosts running php applications.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<VirtualHost *:80> ServerAdmin webmaster@example.com DocumentRoot /var/www/example.com ServerName example.com ErrorLog logs/example.com-error_log CustomLog logs/example.com-access_log common AccessFileName .htaccess ### suPHP ### suPHP_Engine on suPHP_UserGroup webdev1 webdev1 suPHP_AddHandler x-httpd-php AddHandler x-httpd-php .php .php3 .php4 .php5 <Directory /var/www/example.com/> Options +Indexes FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> |
5. Chown the documentroot to the user who will be the webmaster
Command: chown -Rf webdev1:webdev1 /var/www/example.com
6. Disable DSO (mod_php)
Command: mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable
7. Restart the web server
Command: service httpd restart
8. If using SSL (https) add the following to your /etc/httpd/conf.d/ssl.conf file
Command: vi /etc/httpd/conf.d/ssl.conf
1 2 3 4 5 6 |
##suPHP## suPHP_Engine on suPHP_UserGroup webdev1 webdev1 suPHP_AddHandler x-httpd-php AddHandler x-httpd-php .php .php3 .php4 .php5 ##suPHP end## |