31
Installing Apache2 and PHP 5.4 from source on Ubuntu 11.10
This guide will show you how to install Apache 2.2 (2.2.21) and PHP 5.4 and MySQL 5.6 from the latest source
First, we will make sure that the development environment and libraries are install on your server
Setup Development Environment tools and libraries
sudo apt-get update
sudo apt-get -y -q install make g++ flex bison build-essential zlib1g-dev binutils cmake
sudo apt-get -y -q install libmcrypt-dev libmhash-dev libxslt1-dev libtidy-dev libbz2-dev libxml2-dev libssl-dev libmysqlclient16 libmysqlclient16-dev
sudo apt-get -y -q install libpng12-dev libpng12-0 libpng3 libjpeg62 libjpeg62-dev libxpm-dev libpcre3 libpcre3-dev zlib1g zlib1g-dev libltdl-dev libltdl7
sudo apt-get -y -q install pkg-config libcurl4-openssl-dev libfreetype6 libfreetype6-dev libc-client2007e libc-client2007e-dev libkrb5-3 libkrb5-dev
sudo apt-get -y -q install openssl libglobus-openssl libglobus-openssl-dev libcurl4-openssl-dev libicu-dev libicu44 libpspell-dev
sudo apt-get -y -q install linux-libc-dev libc-dev-bin libc-bin libc-client2007e-dev eglibc-source libkrb5-3 libkrb5-dev libkrb53 libkrb5support0
sudo apt-get -y -q install libncurses5-dev libncurses5 ncurses-base ncurses-bin ncurses-term libaio-dev
Installing Apache 2.2.21 from source
wget http://apache.mirror.nexicom.net//httpd/httpd-2.2.21.tar.gz
tar zxf httpd-2.2.21.tar.gz cd httpd-2.2.21
./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-ssl --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so
make -s
sudo make install
sudo mkdir /var/www/
sudo chgrp -R www-data /var/www/
Configure Apache2 to start automatically when system is rebooted
runlevel (should output a number like 2)
cd /etc/rcX.d/ (replace X with the number you saw when you run 'runlevel')
sudo ln -s -T /usr/local/apache2/bin/apachectl S80apache
Easy enough, Apache2 is already installed and ready to serve normal HTML web pages.
You can control the status of the web server with these commands:
Stop the web server
/usr/local/apache2/bin/apachectl stop
Start the web server
/usr/local/apache2/bin/apachectl start
Installing MySQL 5.6 from source
sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo mkdir /var/log/mysql/
sudo chgrp -R mysql /var/log/mysql/
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.3-m6.tar.gz/from/http://mirror.csclub.uwaterloo.ca/mysql/
mv index.html mysql.tar.gz
tar zxf mysql.tar.gz
cd mysql-5.6.3-m6/
mkdir bld
cd bld
cmake -DBUILD_CONFIG=mysql_release ..
sudo make install
cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data
sudo chown -R root .
sudo chown -R mysql data
sudo cp support-files/my-medium.cnf /etc/my.cnf
sudo cp support-files/mysql.server /etc/init.d/mysql.server
Edit configuration file sudo nano /etc/mysql/my.cnf
under [MYSQLD] edit or add the following lines:
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
to save
to exit
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
sudo /usr/local/mysql/bin/mysqladmin -u root password "NEW PASSWORD"
Installing PHP 5.4 from source
wget http://downloads.php.net/stas/php-5.4.0beta2.tar.gz
tar zxf php-5.4.0beta2.tar.gz
cd php-5.4.0beta2/
'./configure' '--disable-short-tags' '--enable-exif' '--with-zlib' '--with-bz2' '--with-openssl' '--with-pcre-regex' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-iconv' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-xsl' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-calendar' '--enable-mbstring' '--enable-ftp' '--enable-bcmath' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' '--enable-calendar' '--without-pear' '--enable-mbstring' '--disable-cli' '--with-png-dir=/usr/lib/libpng12.so' '--with-mysql-sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' --with-imap-ssl --with-kerberos --with-curl --enable-ftp
make -s
sudo make install
If you want to configure PHP in development mode, run this line:
sudo cp php.ini-development /usr/local/lib/php.ini
If you want to configure PHP in production mode, run this line:
sudo cp php.ini-production /usr/local/lib/php.ini
Configuring Apache2 to run PHP scripts
wget http://apache.parentinginformed.com/httpd/mod_fcgid/mod_fcgid-2.3.6.tar.gz
tar zxf mod_fcgid-2.3.6.tar.gz
cd mod_fcgid-2.3.6
APXS=/usr/local/apache2/bin/apxs ./configure.apxs
make
sudo make install
You also need to edit Apache2 config file
Order allow,deny
Allow from all
AllowOverride All
Options MultiViews Indexes Includes FollowSymLinks ExecCGI

