Installing LAMP with suPHP

From PrgmrWiki

This tutorial will show you how to setup a lamp (Linux Apache Mysql PHP) server with suPHP (so php is executed as the user and not as the apache user for more security) and i will be using the ubuntu distro image for this tutorial

Log in as root

Update/Upgrade your server (to make sure everything is up to date and the package listing is the latest version)

# apt-get update
# apt-get upgrade

Install the needed packages for our lamp services (Apache, Mysql, PHP5)

# apt-get install apache2 php5-cgi mysql-server

(If you do not want to setup suphp you can stop here)

I have had no luck using the stock package for suphp so we are going to compile it ourself

# apt-get build-dep libapache2-mod-suphp

Download, Extract, Compile, and Install

# wget
# tar vfxz suphp-0.7.1.tar.gz
# cd suphp-0.7.1
# ./configure --prefix=/usr --sysconfdir=/etc/ --with-apache-user=www-data --with-setid-mode=owner --with-apxs=/usr/bin/apxs2 --disable-checkpath
# make install

open /etc/suphp.conf in your favorite editor (Note you will have to create it)

Here is my suphp configuration you are free to use it

;Path to logfile


;User Apache is running as

;Path all scripts have to be in

;Path to chroot() to before executing script

; Security options

;Check whether script is within DOCUMENT_ROOT

;Send minor error messages to browser

;PATH environment variable

;Umask to set, specify in octal notation

; Minimum UID

; Minimum GID

;Handler for php-scripts

;Handler for CGI-scripts

once you have made your suphp.conf please open /etc/apache2/apache2.conf and add the following

# Load suPHP module for apache
LoadModule suphp_module       /usr/lib/apache2/modules/

# Add php handler to apache for suphp
suPHP_Engine on
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php

now restart apache

/etc/init.d/apache2 restart

Congratulations you now have a working LAMP with suPHP installed

Please note the default page will not load because the uid/gid is below the minimum id requirements please chown the dir or move it in /etc/apache2/sites-enabled/000-default to a new location

if you have any questions setting this up please feel free to email me at prgmr-wiki <at> chr1831 <dot> com with the subject Installing LAMP with suPHP