easyengine (ee) note: If you are using easyengine, you can accomplish everything in this article using following command:
ee stack install --all
A complete WordPress-Nginx setup will involve PHP, MySQL, Nginx stack and on the top of it WordPress itself.
If you already have PHP, MySQL & Nginx up & running then you may jump to next part i.e Nginx configuration for different WordPress
I am assuming few things before you start.
- You have a Ubuntu server up and running. This guide may work on other Debian based distros but this is tested on Ubuntu 12.04 LTS only.
- You have shell access to your Ubuntu server with sudo privilege or you have direct root-user access.
Installing PHP 5.6
We are going to use latest PHP 5.6 as it is much faster & better than PHP 5.3 and PHP 5.4.
As official repo for Ubuntu 12.04 LTS contains PHP version 5.3 only, we will use a launchpad repo maintained by Ondřej Surý
Run following codes to add launchpad repo to apt-sources:
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php
Press “enter” key whenever asked!
This is must, otherwise next command may end up installing PHP 5.3!
sudo apt-get update
Now, run following to install PHP itself
sudo apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt
Check PHP Version
Run following command…
You will see following output…
PHP 5.6.29-1+deb.sury.org~xenial+1 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
We use Percona-MySQL everywhere for extra features and up-to-date Ubunut builds they maintain.
Add Percona Repo
Execute following commands:
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A echo "deb http://repo.percona.com/apt `lsb_release -cs` main" >> /etc/apt/sources.list.d/percona.list echo "deb-src http://repo.percona.com/apt `lsb_release -cs` main" >> /etc/apt/sources.list.d/percona.list apt-get update
Installing percona-mysql server
sudo apt-get install percona-server-server-5.6 percona-server-client-5.6
Above wizard should ask you to enter a mysql password for user
root. If it doesn’t, then run the following command to change MySQL password.
sudo mysqladmin -u root password NEWPASSWORD
Please note that above command will not help you in case you forget your mysql root password in future.
If you want to send mails from your WordPress, you will need a SMTP server. You can use a remote SMTP server like gmail.com for this. But I prefer using postfix package to run a SMTP server locally.
In simple words, if you skip this step and do not configure remote SMTP server with WordPress either, your WordPress will not be send email notifications for comments, etc.
sudo apt-get install postfix
It will take you through few steps. The important one are:
- Select option – Internet Site
- Hostname – generally your main domain i.e example.com. Recommended – a FQDN like mail.example.com
You no need to touch other options. Just restart mail service to be safe.
Testing your mail config:
Run following PHP code with firstname.lastname@example.org replaced by your mail id:
php -a mail ('email@example.com', "Hello from nginx!", "My email setup works!"); exit ();
Alternatively you can use check-mail WordPress Plugin after your WordPress setup completes to be sure that your WordPress can send emails.
Ubuntu official repos come with a Nginx package but I prefer using launchpad repo maintained by Nginx team.
sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
If you prefer to use Nginx package in Ubuntu repo, you can simply run following command:
sudo apt-get install nginx-full
At this point, we are done with installing prerequisite for WordPress.
As technology evolves, we keep upgrading our installation. This article is “how” we work here at rtCamp. So this article need to be changed over time.
Oct 15, 2013
- Replaced PHP 5.4 with PHP 5.5
- Removed APC
- Using PHP’s built-in zend-opcache for opcode-cache.
- Using memcache for user/data-cache requirement
- Switched to mysql native driver for PHP (php-mysqlnd package)
- Replaced oracle-mysql with percona-mysql. Mysql 5.6 at the time of writing this article.