Web Hosting Forum | Lunarpages

Author Topic: PHP Upgrade On Xen VPS with LPCP and SuPHP install for Xen VPS with LPCP  (Read 23685 times)

Offline JoshuaK

  • Pong! (the videogame) Master
  • *****
  • Posts: 26
    • Check Out My Blog
So as promised, here is the walk through on how to install SuPHP on LPCP for dedicated and Xen VPS. As an added bonus, I am going to show you how to update your PHP to the latest stable version, the easy way.

First, you need to know how to login via ssh to your Linux Dedicated Server or Xen VPS, if your unfamiliar with how to do that, please visit the following link and follow the steps there. 


Next, we are going to download the Atomic Rocket Turtle Repo, and install it. This can be done by simply running the following command from shell.

Code: [Select]
wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
What this does is installs a new repository for where your server can look for updates. Why is this needed? Because the default centos repos don't update PHP beyond the default version that gets shipped with the major release of the OS.

Now to actually update your PHP to the latest stable build available, simple run the following :

Code: [Select]
yum update php
Follow the prompts, and wait for the update to complete. To confirm the update has worked run :

Code: [Select]
php -v
You should see something like the following indicating the version of PHP installed.

Code: [Select]
[root@server ~]# php -v
PHP 5.2.13 (cli) (built: Mar  2 2010 15:56:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
To see a list of all the php modules that are available to you, simply run :

Code: [Select]
yum list php-*  |grep ".art"
and run :

Code: [Select]
yum install name-of-the-package
A common one is IonCube, so to install it run :

Code: [Select]
yum install php-ioncube-loader
If this is all you came here for, your done, just restart apache to gain the effect of your freshly installed PHP.

For a SuPHP install, it does require that you make changes to configuration files, so if you are uneasy about doing that, you may want to request help.  My rule of thumb when making any changes to configuration files, make a backup first.  Even if you have edited files in linux a million times before, all it takes is one "fat finger" moment to mess up a conf file to the point of where it doesn't load.

Code: [Select]
cp /path/to/file /path/to/file.bak
From here, if you are not familiar with a text editor in linux, I recommend you read up on one of the following:

vi - http://www.lagmonster.org/docs/vi.html

nano - http://mintaka.sdsu.edu/reu/nano.html

nano if by far easier, but vi is by far more feature full and powerful.  This walk through is referenced in vi, but can easily be adapted to nano.

To start, make a directory to store the files for suphp.  For this tutorial this forlder should be /root/setup :

Code: [Select]
mkdir /root/setup
then navigate to that directory :
Code: [Select]
cd /root/setup
Download the lastest version of suphp from http://www.suphp.org.  The link is at the top of the page, so it is easy to grab. At the time of writing this walk through, version 0.7.1 is the latest version released.

Download the file by running :

Code: [Select]
wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
Extract the suphp files :

Code: [Select]
tar -xvzf suphp-0.7.1.tar.gz
And navigate into the directory :

Code: [Select]
cd suphp-0.7.1
From this point you will need to install the tools used to install suphp.  Run the following command to install the compilers and apache devel tools :

Code: [Select]
yum install gcc gcc-c* httpd-devel* apr*
Follow the prompts to install the compilers and devel tools, once that has completed, you can run the following command to configure SuPHP, make it and install it.

Code: [Select]
./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config \
--with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-setid-mode=paranoid \

make && make install

Congratulations, you now have SuPHP installed, but apache isn't using it yet.  This is where the configuration changes come into play.

First, create a file using your text editor at this location :

Code: [Select]
and insert the following lines of code into the file :

Code: [Select]
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddHandler x-httpd-php .php .php5 .php4 .php3 .phtml
suPHP_ConfigPath /etc
suPHP_AddHandler x-httpd-php
DirectoryIndex index.php

Save the file.

Next we need to move the old php entries, so we dont have conflicts.

Code: [Select]
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak
Next, create the SuPHP binary configuration at :

Code: [Select]
And insert the following lines :
Code: [Select]

Save the file.

Next we must edit the main apache conf file, to first disable suexec (it conflicts with suphp) and adjust the virtual host directories to use the correct users.

Code: [Select]
/etc/httpd/conf/httpd.conf with your file editor.

find the line that looks like this :

Code: [Select]
LoadModule suexec_module modules/mod_suexec.so
And put a "#" in front, so that it looks like :

Code: [Select]
#LoadModule suexec_module modules/mod_suexec.so(FYI this is commenting out this line of code)

(2nd FYI, while your in here, you may want to adjust your "AllowOverride None" to "AllowOverride All" to allow .htaccess redirects to work if you haven't already.)

Now down to the virtual hosts, we need to make changes for every account that is created so far in LPCP.  Change the line that looks like :
Code: [Select]
SuExecUserGroup username username
to :
Code: [Select]
#SuExecUserGroup username username
and add a line directly below it that looks like :
Code: [Select]
suPHP_UserGroup username username
(obviously replace username with the correct username of the account)

from there, you should be able to restart apache, and see if your site works.
Code: [Select]
service httpd restart
If your site works, great.  If your page pulls up a 500 error, check the ownership of your files and make sure your file permissions are no higher then 755

To do the permissions the easy way run the following script :

Code: [Select]
find /home/*/public_html/ -perm 777 -exec chmod 755 {} \;
(No easy way to do file ownership)

Once you can confirm that your site, or at the very least suphp is working, there is one last modification you want to make.

In the file :

Code: [Select]
you want to make sure that when you add new domains, it adds SuPHP for you, so comment out the :

Code: [Select]
SuExecUserGroup ##loginname## ##loginname##
And replace it with :

Code: [Select]
suPHP_UserGroup ##loginname## ##loginname##
And if you followed all the steps, you should be all set.

Joomla requires sessions, so it requires you edit your php.ini file in :

Code: [Select]
find the line that says :

Code: [Select]
session.save_path = "/var/lib/php/session/"
and change it to :

Code: [Select]
session.save_path = "/tmp/session"
then run :

Code: [Select]
mkdir /tmp/session
chmod 777 /tmp/session

restart apache, and you should be good to go.

Let me know if I have missed anything, or you have any comments or questions.

Offline rtedgar

  • Trekkie
  • **
  • Posts: 14
Hi Joshua,
Works great!

Bob Edgar
« Last Edit: March 20, 2011, 02:04:19 PM by rtedgar »

Offline wilmatan

  • Intergalactic Cowboy
  • *****
  • Posts: 51
Great JOB in there Joshua!

Keep it up!!
 ;D ;D ;D ;D

Offline La Nube2012

  • Newbie
  • *
  • Posts: 1
Re: PHP Upgrade On Xen VPS with LPCP and SuPHP install for Xen VPS with LPCP
« Reply #3 on: November 10, 2011, 05:57:51 PM »
Bueno todo Josh!  Sigue con el buen trabajo!


Share |