Support Online
Skip to main content

Nginx Installation: Guide to Installing WordPress on Ubuntu 14.04

What Will You Learn in This Guide?

In this guide, you will learn how to install WordPress with Nginx web server on Ubuntu 14.04.
Aim; is to create a fast, secure and scalable WordPress infrastructure.
All steps are addressed in accordance with real server scenarios.

🧠 Technical Summary

Main Technical Topic:
WordPress installation with Ubuntu 14.04 + Nginx + MySQL + PHP (LEMP).

Solved Problem:
Error-free configuration of web server, database and CMS integration.

Steps Followed:

  • MySQL database and user authorization
  • Downloading WordPress files
  • wp-config.php configuration
  • Making file permissions Nginx compatible
  • Setting Nginx server blocks
  • Completing the installation via web interface

1️⃣ Prepare MySQL Database

WordPress stores all content in the MySQL database.

mysql -u root -p


CREATE DATABASE wordpress;
CREATE USER wp_kullanicisi@localhost IDENTIFIED BY 'guclu_sifre';
GRANT ALL PRIVILEGES ON wordpress.* TO wp_kullanicisi@localhost;
FLUSH PRIVILEGES;
exit;

2️⃣ Download WordPress Files


cd ~
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz


sudo apt-get update
sudo apt-get install php5-gd

3️⃣ WordPress Configuration


cd ~/wordpress
cp wp-config-sample.php wp-config.php


curl -s https://api.wordpress.org/secret-key/1.1/salt/


nano wp-config.php


define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_kullanicisi');
define('DB_PASSWORD', 'guclu_sifre');

4️⃣ Move Files to Web Directory


sudo mkdir -p /var/www/html
sudo rsync -avP ~/wordpress/ /var/www/html/
cd /var/www/html/
sudo chown -R genixnode:www-data *

5️⃣ Configure Nginx Server Blocks


sudo nano /etc/nginx/sites-available/wordpress


server {
listen 80;
root /var/www/html;
index index.php index.html;
server_name tr1-node01.ornek.com;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}


sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart

❓ Frequently Asked Questions (FAQ)

1. Why should I use Nginx instead of Apache? Nginx consumes less resources and is faster in high traffic.

2. I'm getting a database connection error, what should I do? Check that the information in wp-config.php matches MySQL exactly.

3. Why are file permissions given to the www-data group? Nginx and PHP-FPM work with this user, WordPress is required for write permission.


🎯 Result

Your WordPress site now runs efficiently on Nginx. You can expand the infrastructure with themes, plugins and SSL configurations. You can implement this installation in minutes on the GenixNode infrastructure 🚀