
How To: Install NginX, PHP-FPM, MySQL, PHP 5.3.10 & WordPress on Ubuntu (Part 1 of 2)
I’ve used a Linode 512MB VPS running Ubuntu 10.04 LTS for this tutorial. They’re one of the best out there in terms of speed, reliability and performance.
First, let’s start with installing NginX. The easiest way to install NginX on Ubuntu is via apt-get, it installs NginX with a standard configuration, so you won’t have to manually install NginX unless you’re using 3rd party modules or a more advanced configuration.
Before beginning with this tutorial, it is recommended to follow this (Howto: Install NginX on Ubuntu 10.04 (or newer) 32bit via apt-get) tutorial if you have 32bit Ubuntu or this (How to: Install NginX on Ubuntu 10.04 64bit via apt-get) tutorial if you have 64bit Ubuntu.
apt-get install nginx
Once you’re done with that, it’s time to install the required libraries. It will not take much time as I’ve already prepared a list for you.
apt-get install wget nano htop binutils cpp flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl m4 libpcre3 libpcre3-dev libssl-dev libpopt-dev lynx make perl perl-modules openssl unzip zip autoconf2.13 gnu-standards automake libtool bison build-essential zlib1g-dev ntp ntpdate autotools-dev g++ bc subversion psmisc libmysqlclient-dev libcurl4-openssl-dev libjpeg62-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev imagemagick
If the above command gives an error about unmet dependencies, then run:
aptitude install wget nano htop binutils cpp flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl m4 libpcre3 libpcre3-dev libssl-dev libpopt-dev lynx make perl perl-modules openssl unzip zip autoconf2.13 gnu-standards automake libtool bison build-essential zlib1g-dev ntp ntpdate autotools-dev g++ bc subversion psmisc libmysqlclient-dev libcurl4-openssl-dev libjpeg62-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev imagemagick
Now, we’re going to install MySQL using apt-get.
apt-get install mysql-server
Once you’ve installed the above libraries, it’s time to install PHP. We’re going to install PHP manually with our own custom configuration.
mkdir ~/temp_space cd ~/temp_space wget http://in.php.net/get/php-5.3.10.tar.gz/from/us.php.net/mirror -O php.tar.gz tar xzvf php.tar.gz cd php-5.3.10
We’ll be working in the folder php-5.3.10, so don’t cd away from it.
Run the following command:
'./configure' '--prefix=/etc/php' '--with-config-file-path=/etc/php' '--with-curl' '--with-pear' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-xpm-dir' '--with-freetype-dir' '--with-t1lib' '--with-mcrypt' '--with-mhash' '--with-mysql' '--with-mysqli' '--with-pdo-mysql' '--with-openssl' '--with-xmlrpc' '--with-xsl' '--with-bz2' '--with-gettext' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--enable-fpm' '--enable-exif' '--enable-wddx' '--enable-zip' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-mbstring' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-shmop' '--enable-dba' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm'
If the above command doesn’t return any error, then continue ahead with the install otherwise, make the required changes.
Once you’ve executed the statement above, run this command while you’re still in the directory php-5.3.3 .
make && make install
After executing the above command, execute the following set of commands. Again, do not cd away from the directory php-5.3.3.
mkdir /var/log/php-fpm chown -R www-data:www-data /var/log/php-fpm cp -f php.ini-production /etc/php/php.ini chmod 644 /etc/php/php.ini cp /etc/php/etc/php-fpm.conf.default /etc/php/etc/php-fpm.conf cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod 755 /etc/init.d/php-fpm update-rc.d -f php-fpm defaults
Now we also have to install the PHP PEAR libraries:
apt-get install php5-dev php-pear
You can now change your current directory. Now, we have to install Imagick. To do that, you can just use pecl.
pecl install imagick
Imagick extension has now been installed, you just need to include it in the php.ini file.
nano /etc/php/php.ini
Find the line which says ‘extension’, without the quotes.
Add the following line next to it:
extension = imagick.so
If you get an error saying extension directory not found, then you just have to change the extension_dir variable in php.ini file. Once you install imagick.so, pecl will print the location of the extension such as /usr/lib/php5/20090626+lfs/imagick.so.
Add the /usr/lib/php5/20090626+lfs/ to the extension_dir variable in php.ini.
The rest will be covered in the next part of the tutorial.