• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Tuesday, May 13, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How To Install WordPress on a LEMP Configuration

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
15
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Step One: Update existing packages
  3. Step Two: Install Nginx
  4. Step Three: Install PHP 5.5
  5. Step Four: Install MySQL
  6. Set Timezone (conditional)
  7. Step Five: Configuring Nginx to serve WordPress
  8. Step Six: Configure PHP
  9. Step Seven: Setting up the MySQL database
  10. Step Eight: Installing the WordPress files
  11. Want to contribute?


Introduction

In this tutorial, you’ll learn how to install WordPress on a freshly created instance. I’ll demonstrate the installation on an Ubuntu 14.04 server. These instructions may also work on older versions of Ubuntu and Debian.

So, let’s start.

Step One: Update existing packages

apt-get update && apt-get upgrade

Step Two: Install Nginx

Nginx is a high performance lightweight web server designed with the purpose of delivering large amounts of static content with efficient use of system resources. In contrast to Apache, Nginx uses an asynchronous event-driven model which provides more predictable performance under load.

Let’s add a third-party repository to install the latest version of Nginx (1.6.1).

sudo apt-get install python-software-properties
add-apt-repository -y ppa:rtcamp/nginx
sudo apt-get update 
sudo apt-get install nginx
service nginx start

Now, let’s test if the server is up and running.

http://YOUR-VPS-IP

It should take you to Nginx’s default landing page.

Step Three: Install PHP 5.5

PHP is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Let’s install the latest version of PHP on our server.

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
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

If you want to check your PHP version, run the following command:

php -v

You will see something like this.

PHP 5.5.16-1+deb.sury.org~trusty+1 (cli) (built: Aug 25 2014 10:24:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
withZendOPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

Now, we’ll make a slight configuration change to make our setup more secure. Open the main php5-fpm configuration file with root privileges:

sudo nano /etc/php5/fpm/php.ini

Press Ctrl+W and search for cgi.fix_pathinfo=. Uncomment it (delete 😉 and change 1 to 0. After changes, the line should look like this:

cgi.fix_pathinfo=0

Save (Ctrl+O) and close the file (Ctrl+X).

Now, we just need to restart our PHP processor by typing:

sudo service php5-fpm restart

Step Four: Install MySQL

To store and manage databases, we need to install MySQL. You can easily install it by typing the following in the console:

sudo apt-get install mysql-server

During the installation process, you will be asked to set a root password for MySQL. Once you have set the root password, we will have to tell MySQL to generate the directory structure where it will store databases.

sudo mysql_install_db

Let’s finish it up by running a security script that will modify some default insecurities.

sudo mysql_secure_installation

Just type the MySQL root password and type n if you don’t want to change it. After that, type y to every question.


Set Timezone (conditional)

By default, the timezone of your server is UTC. If you’re living in a different timezone, you can change it by typing in the following command:

sudo dpkg-reconfigure tzdata

At this point, your LEMP server is up and running.

Step Five: Configuring Nginx to serve WordPress

Let’s start our WordPress installation by creating an Nginx server block for our site.

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

Paste the following code there:

server {
        listen 80;

        root /var/www/wordpress;
        index index.php index.html index.htm;

        server_name domain.com;

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        } 
location / {
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }


        location ~ /.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+/.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

location = /favicon.ico {
        access_log off;
        log_not_found off;
        expires max;
}
location = /robots.txt {
        access_log off;
        log_not_found off;
}

# Cache Static Files For As Long As Possible
location ~*
/.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$
{
        access_log off;
        log_not_found off;
        expires max;
}
# Security Settings For Better Privacy Deny Hidden Files
location ~ //. {
        deny all;
        access_log off;
        log_not_found off;
}
# Return 403 Forbidden For readme.(txt|html) or license.(txt|html)
if ($request_uri ~* "^.+(readme|license)/.(txt|html)$") {
    return 403;
}
# Disallow PHP In Upload Folder
location /wp-content/uploads/ {
        location ~ /.php$ {
                deny all;
        }
}
}

This is a well tuned WordPress configuration file with permalinks support. Save (Ctrl+O) and close the file (Ctrl+X). Let’s enable the server block by symlinking:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

Next, we’ll delete the Nginx default server block.

sudo rm /etc/nginx/sites-enabled/default

Now, we’ll tune the main Nginx configuration file:

sudo nano /etc/nginx/nginx.conf

Make sure that the number of worker processes is equal to the number of cores in your instance.

user www-data;
worker_processes 1;
pid /run/nginx.pid;

Add use epoll; to the events block.

events {
worker_connections 4096;
multi_accept on;
use epoll;
}

Add client_max_body_size and server_tokens off directive. Set keepalive_timeout to 30 seconds.

        ##
        # Basic Settings
        ##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size  100m;


        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

Make sure that the whole Gzip settings block looks like this:

        ##
        # Gzip Settings
        ##

gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

Save (Ctrl+O) and close the file (Ctrl+X). Then restart the server:

sudo service nginx restart

Step Six: Configure PHP

If you want to upload files more than 2mb to your WordPress site, you have to increase PHP upload size variables in php.ini.

sudo nano /etc/php5/fpm/php.ini

Now, press Ctrl+W and search for “upload_max_filesize” and set it to 100m.

upload_max_filesize=100M

Do the same with post_max_size. post_max_size needs to be the same size or larger than upload_max_filesize.

post_max_size=100M

Restart PHP.

sudo service php5-fpm restart

Step Seven: Setting up the MySQL database

In this step, we’ll create the database user and tables. Go ahead and log into the MySQL shell:

mysql -u root -p

Log in using your MySQL root password. We will need to create a WordPress database, along with a user in the database. First, let’s make the database (feel free to give it whatever name you like):

CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

After that, we need to create a new user. Please replace the database, name, and password with whatever you prefer:

CREATE USER wordpressuser@localhost;
Query OK, 0 rows affected (0.00 sec)

Set a password for your new user:

SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
Query OK, 0 rows affected (0.00 sec)

Finish up by granting all privileges to the new user. Without this command, the WordPress installer will not be able to start up:

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

Then refresh MySQL:

FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Exit the MySQL shell:

exit

Step Eight: Installing the WordPress files

We’re almost done. Let’s proceed to installing WordPress.

First navigate to the site root directory:

mkdir /var/www/
cd /var/www/

Now, download the latest version of WordPress:

wget http://wordpress.org/latest.tar.gz

Extract it from the archive:

tar -xzvf latest.tar.gz

Give the permissions of /var/www/wordpress to www-data user. It will allow future automatic updating of WordPress plugins and file editing with SFTP.

sudo chown -R www-data:www-data wordpress/
sudo usermod -a -G www-data www-data

You’re done! Your new WordPress site is now ready. Just navigate to your website and finish the installation.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Gitea on Fedora 29

Next Post

Install MediaWiki on the One-Click LEMP Application

Next Post

Install MediaWiki on the One-Click LEMP Application

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet