Installing LAMP with suPHP
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 http://www.suphp.org/download/suphp-0.7.1.tar.gz # 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
[global] ;Path to logfile logfile=/var/log/suphp.log ;Loglevel loglevel=info ;User Apache is running as webserver_user=www-data ;Path all scripts have to be in ;docroot=/ ;Path to chroot() to before executing script ;chroot=/tmp ; Security options allow_file_group_writeable=false allow_file_others_writeable=false allow_directory_group_writeable=false allow_directory_others_writeable=false ;Check whether script is within DOCUMENT_ROOT check_vhost_docroot=false ;Send minor error messages to browser errors_to_browser=true ;PATH environment variable env_path=/bin:/usr/bin ;Umask to set, specify in octal notation umask=0077 ; Minimum UID min_uid=100 ; Minimum GID min_gid=100 [handlers] ;Handler for php-scripts x-httpd-php="php:/usr/bin/php5-cgi" ;Handler for CGI-scripts x-suphp-cgi="execute:!self"
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/mod_suphp.so # 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