I have been dabbling with VPS’s for a while now and have always wanted recipes I can work with and come back to when I do my setup. I don’t want to search for what packages I need to install and have missed.
Here’s a basic setup I do. This will of course be reserved as a reference for anyone needing to setup PHP on a blank server (Ubuntu 12.04).
Chances are, you would need a web server. My choice has always been Apache.
sudo apt-get install apache2
Here, we are going to install the needed modules for Apache to work with PHP.
sudo apt-get install libapache2-mod-php5
First of all, you would need to install MySQL.
sudo apt-get install mysql-server mysqltuner
mysqltuner is a performance script to tune performance for MySQL.
Secure your MySQL
It will present you with a few questions, starting with your MySQL password. You will then secure parts of your MySQL installation.
If you’re like me, you would want to get the latest PHP versions available for your system version. You may need to skip this if you want to install the default distributed PHP version for your system.
Add repository for latest PHP version
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php5 sudo apt-get update sudo apt-get upgrade
sudo apt-get install php5-common php5-mysql php5-xmlrpc php5-cgi php5-curl php5-gd php5-cli php5-fpm php-apc php-pear php5-dev php5-imap php5-mcrypt
Secure PHP Installation(optional, but recommended)
sudo apt-get install php-suhosin
Check your PHP version
You may get something like this depending on your PHP version:
PHP 5.3.6-13ubuntu3.10 with Suhosin-Patch (cli) (built: Mar 11 2013 14:30:28) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
PHP 5.4.17RC1 (cli) (built: Jun 22 2013 19:27:26) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
PHP 5.5.1-1~precise+1 (cli) (built: Jul 22 2013 07:42:13) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.2-dev, Copyright (c) 1999-2013, by Zend Technologies
A tutorial on how to host multiple sites will be arranged in a couple of weeks. Stay tuned!