link Install suPHP on Centos 6← Back

I'm assuming you've already successfully installed Apache, MySQL and PHP. You will also need the php-cli module installed as detailed.

  1. Add the RepoForge repo if you don't already have it.
    32-bit:
    rpm -ivH http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
    64-bit:
    rpm -ivH http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  2. Install the packages
    yum install -y php-cli mod_suphp
  3. Edit /etc/suphp.conf and adjust lines 25 and 28 respectively
    x-httpd-php="php:/usr/bin/php-cgi"
    x-suphp-cgi="execute:!self"
    
  4. Set PHP session directory group ownership permission
    groupadd phpsession
    chgrp phpsession /var/lib/php/session
    
  5. For each VirtualHost you wish to operate under suPHP, you will need to add the following to their Apache config file in /etc/httpd/conf.d, replacing username and group respectively
    suPHP_Engine on
    suPHP_UserGroup username group
    AddHandler x-httpd-php .php .php3 .php4 .php5
    suPHP_AddHandler x-httpd-php
    
  6. For each user operating under suPHP, you will need to add them to the phpsession group you just created otherwise they will get errors about session creation. Replace username respectively
    usermod -a -G phpsession username
  7. If you get a 500 Internal Server Error message, your PHP scripts and/or directories probably have incorrect permissions. You can reset all directories to rwxr-x-r-x (ie. 0755) and all files to rwxr--r-- (ie. 0644) by running the following at your HTML root
    find . * -type d -exec chmod 0755 {} +
    find . * -type f -exec chmod 0644 {} +
    

Comments

Gravatar

2015-05-09

Howdy! I realize this is kind of off-topic but I had to ask.
Does managing a well-established website such as yours require a massive amount work?
I'm completely new to running a blog but I do write in my journal on a daily basis.
I'd like to start a blog so I can share my own experience and
feelings online. Please let me know if you have any suggestions or tips for new aspiring bloggers.
Appreciate it!

Gravatar

2013-10-31

When I wrote this article I already had a functioning Apache/PHP/MySQL system.

After re-testing on the CentOS 6.4 minimal ISO, Apache and PHP are installed automatically as dependencies. MySQL and it's associated PHP module still need to be installed manually as well as any other PHP modules you plan to use.

Gravatar

Lindsay

2013-10-31

Your opening comments states "I'm assuming you've already successfully installed Apache, MySQL and PHP." Do we actually need Apache and PHP to be installed separately? Don't this get installed automatically along with mod_suphp?

Gravatar

Driven

2013-09-03

Hi,

Since installing suphp I have a problem with phpmyadmin, I have php which appears instead to be executed, I do not know how to solve ...

Can you help me please?

Gravatar

2013-07-23

Adding the user to the group gives the user write access to the PHP session directory, /var/lib/php/session.

The actual session files are created with 0600 permissions so the only security risk is someone sharing their PC and having their session cookie automatically read when someone else uses their PC to visit the same site.

Gravatar

2013-07-23

isnt this line a security risk?

usermod -a -G phpsession username

Gravatar

2012-07-09

Thanks for this great write-up! I had been meaning to enable suPHP for a while on my CentOS 6 boxes, and this article made it super quick and easy!

Post a comment