IMPORTANT: Not covered here:

1. Shared Hosting
Your shared host have setup this up for you already either by doing what I’ve described above on an enterprise level or they have chrooted environments with this enabled and already setup for customers.

2. Provide FTP or sFTP access (preferred)
This option requires a user setup with correct owner/group and file permissions setup for the vhost’s documentroot

[divider]

What is a PHP Handler?

In order to run a site that includes PHP code, the webserver must interpret the PHP code and generate a page when visitors access the website. It interprets the code based on which PHP library and handler or interpreter you are using, such as PHP 4.x or PHP 5.x. Imagine you have a library with certain contents  or books (such as: PHP 5.4 or PHP 4.3), and you have a guy in charge of handling that library (the interpreter) who decides how the information is handled, the interpreter in this case, is one of the handler combinations listed below.

1. PHP handlers load the libraries so that they can be used for interpretation.
2. PHP handlers determine how PHP is loaded on the server.

Dedicated Server or VPS

Options

1. CGI
2. suPHP
3. FastCGI (mod_fastcgi) + httpd-itk
4. php-fpm + mod_proxy_fcgi
5. DSO (mod_php)

Reason for this

WordPress requires write access to it’s own directories to perform updates and installations of software, most default webserver setups (Apache httpd, nginx, Lighttpd, Cherokee) from major Linux distributions are setup to prevent this (writing to the documentroot) for obvious security reasons. To circumvent this while minimizing any potential damage or security, you need to use a PHP interpreter or handler that will allow you to write to the documentroot, such as options 1 – 4 above..

Purpose

Options 1 – 4 allow for WordPress to write to it’s own directories as the user that specific vhost is running as. In this way, any potential damage is limited to that vhost/documentroot. You will then be able to install plugins and themes, use the WordPress update features or the theme and plugin editors without being prompted for login credentials.

Prerequisites

1. Root or sudo access to the system
2. Strong Understanding of the differences between file/dir ownership and file/dir permissions
3. Strong Understanding directory structure
4. Confortable editing Apache httpd config
5. Comfortable installing software

Common Setup

Our user: webdev1
Our website: example.com
Software: WordPress 3.9.1

1. Setup our user for our new site (webdev1)

Command: useradd webdev

2. Create the documentroot where our new site will live (/var/www/example.com)

Command: mkdir /var/www/example.com

3. Copy or unzip/untar the sites files in the documentroot created in step 1

Command: cd /var/www/example.com
Command: wget http://wordpress.org/latest.zip
Cammand: unzip latest.zip
Command: cd wordpress
Command: mv * ../
Command: cd ../
Command: rm -f wordpress latest.zip

3. Change the group and user ownership on the new documentroot to our user in step 1

Command: chown -Rf webdev:webdev /var/www/example.com

4. Set recursive file and directory permissions:

Command: cd /var/www
Command: pwd
Command: ls
Command: find . -type f -exec chmod 644 {} \;
Command: find . -type d -exec chmod 755 {} \;

5. Edit the Apache httpd vhost config, ours is in: /etc/httpd/conf.d/vhost_example.conf

Note: both of these configurations are setup to diable globally and enable on a per-vhost basis.

Last Modified: 7 Jun, 2014 at 17:41:59