Setting Web Server Nginx WordPress
Introduction
WordPress is one of the most popular content management systems (CMS) and blogging platforms, and Nginx is becoming more and more popular as a web server – even overtaking Apache for certain applications. This guide will show you how to install Nginx on Ubuntu 14.04 and configure it to serve a WordPress website.
Installing Nginx on Ubuntu 14.04
Nginx is included in the standard Ubuntu 14.04 repositories. You can install it by running the following command:
sudo apt-get update
sudo apt-get install nginx
Once the installation is complete, you can start the Nginx service and make sure that it is automatically started on boot with the following commands:
sudo service nginx start
sudo update-rc.d nginx defaults
At this point, Nginx is installed, and running on your system.
Configuring Nginx for WordPress
Once Nginx is installed, it is time to configure it for WordPress. First, you need to create a virtual host configuration file for your domain name. You can do this by creating a new file in the ‘/etc/nginx/sites-available/‘ directory:
sudo nano /etc/nginx/sites-available/example.com
In this file, add the following configuration. Be sure to replace the example values with your own domain name, and the location you want to serve the WordPress files from:
server {
listen 80;
server_name example.com;
root /var/www/wordpress;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Once you have saved the file, you need to enable the virtual host. You can do this by creating a symbolic link from this file to the ‘/etc/nginx/sites-enabled/‘ directory:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Finally, you need to test the configuration for any syntax errors:
sudo nginx -t
If your configuration contains any syntax errors, the output from this command will be detailed. You can edit your configuration file and repeat the test command until the configuration file is error-free.
Once you have a valid configuration, you can restart Nginx for the changes to take effect:
sudo service nginx restart
Nginx is now ready to serve a WordPress website.
Installing WordPress
You can install WordPress by following the official WordPress installation guide.
To start, you can download the latest version of WordPress to your server:
wget http://wordpress.org/latest.tar.gz
Once the download is complete, you can extract the archive with the following command:
tar -xzvf latest.tar.gz
This will extract the WordPress files to your current directory. Move them to the ‘/var/www/wordpress/’ directory, which is specified in your Nginx configuration file.
sudo mv wordpress/* /var/www/wordpress
At this point, you can access the WordPress installation script in your web browser by visiting your domain name or IP address. Follow the on-screen instructions to complete the WordPress installation.
Configuring Nginx for Permalinks
WordPress Permalinks depend on URL rewriting, which is handled by the Nginx configuration file. By default, Nginx does not have any rewrite rules specified. You need to modify your virtual host configuration to include the following code, which will rewrite the URL’s correctly for WordPress Permalinks:
location / {
try_files $uri $uri/ /index.php?args;
rewrite ^/wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
Once you have added this code, you can restart Nginx for the changes to take effect:
sudo service nginx restart
Your WordPress Permalinks should now be working correctly.
Conclusion
By following this tutorial, you have now installed Nginx on your Ubuntu 14.04 server and configured it to serve a WordPress website. With a few simple commands, you can have a web server up and running in no time.
FAQs
Q: What is Nginx?
A: Nginx is a web server software commonly used to serve web applications and static content. It is highly regarded for its performance and scalability.
Q: What version of Ubuntu is required to install Nginx?
A: Nginx is available in the official repositories of Ubuntu 14.04, and can be installed by running sudo apt-get install nginx.
Q: How do I enable URL rewriting for WordPress Permalinks?
A: By adding a rewrite rule to the Nginx configuration file, URL rewriting can be enabled for WordPress Permalinks. See the Configuring Nginx for Permalinks section of this article for more details.
Thank you for reading this article. Please read other articles about web development and web servers.
Related Posts:
- Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Introduction In this article, we will demonstrate how to install Nginx, PHP, MySQL, and phpMyAdmin on an Ubuntu 18.04 server. Nginx is a…
- Install Nginx 1.16 Ubuntu Install Nginx 1.16 Ubuntu Introduction to Nginx 1.16 Nginx 1.16 is a web server that helps you to serve web content quickly, efficiently and securely. It is especially popular with…
- Stop Nginx Ubuntu 16.04 Stop Nginx Ubuntu 16.04 What is Nginx? Nginx is a web server and reverse proxy software. It is open source and widely used on the web. It is used to…
- Nginx Handle Large Upload Data Post Wordpress Nginx Handle Large Upload Data Post Wordpress Why Do We Need to Handle Large Upload Data in Wordpress? WordPress is used on a wide variety of platforms and web servers.…
- Nginx On Ubuntu 18.04 Nginx On Ubuntu 18.04 What is Nginx? Nginx is a free, open-source, high-performance web server software. It is known for its stability, rich feature set, simple configuration, and low resource…
- How To Deactive Nginx Ubuntu How To Deactivate Nginx Ubuntu Introduction Nginx is a web server that’s popular in the Linux world because of its simple configuration, scalability, and performance. The Apache httpd web server…
- Install Laravel Nginx 16.04 Install Laravel Nginx 16.04 What is Laravel? Laravel is an open source PHP framework designed to organize, develop, and easily deploy modern web applications. It is built on the Model-View-Controller…
- How To Install Moodle On Nginx Postgresql Ubuntu How To Install Moodle On Nginx Postgresql Ubuntu Overview of Moodle and Requirements Moodle is an open-source learning management system (LMS) used by educators, businesses, and other organizations to create…
- Tutorial Start Nginx Ubuntu Webserver Tutorial Start Nginx Ubuntu Webserver Step 1: Prerequisites Before we start configuring Nginx as a web server on Ubuntu, we need to make sure we have the following prerequisites: A…
- Step By Step Install Nginx And Phpmyadmin On Ubuntu Step By Step Install Nginx And Phpmyadmin On Ubuntu Introduction Setting up a web server on Ubuntu is easy and straightforward. Nginx is a popular web server for Ubuntu, and…
- Nginx Conf Wordpress Root Directory Nginx Conf Wordpress Root Directory What Is Nginx? Nginx is a powerful web server that can be used to serve static or dynamic content. It has been used by some…
- Install Phpmyadmin On Nginx Ubuntu 18.04 Install Phpmyadmin On Nginx Ubuntu 18.04 Introduction PhpMyAdmin is one of the most popular and widely used web-based database management tools available. It is used for administering, managing and maintaining…
- Upgrade Nginx Ubuntu 18.04 Upgrade Nginx Ubuntu 18.04 Getting Started with Nginx Ubuntu 18.04 Installation Nginx is a high performance web server and reverse proxy. It is written in C and has ways to…
- How To Install Phpmyadmin In Ubuntu 18.04 Nginx How To Install Phpmyadmin In Ubuntu 18.04 Nginx Introduction The MySQL database management system is one of the most popular and powerful open source database systems available today. To make…
- Ubuntu Nginx Fastcgi 7.2 Ubuntu Nginx Fastcgi 7.2 What is Ubuntu Nginx Fastcgi? Ubuntu Nginx Fastcgi is an open-source web server that is used to provide web hosting services on Ubuntu Linux. It provides…
- Install Mysql Pada Nginx Pada Ubuntu Install Mysql Pada Nginx Pada Ubuntu Overview of Nginx and Its Benefits Nginx is a web server, reverse proxy server, and mail proxy server application that is open-source and available…
- Php-Fpm Nginx Ubuntu 18.04 PHP-FPM & Nginx on Ubuntu 18.04 Introduction to PHP-FPM PHP-FPM (FastCGI Process Manager) is an implementation of FastCGI, which is a standard protocol for interfacing external applications with web servers.…
- Bitnami Wordpress Nginx Sent Email Arent Work Bitnami WordPress Nginx Sent Emails Aren't Working What is Bitnami WordPress? Bitnami WordPress is an open source software package specifically designed for quickly setting up and managing a WordPress website.…
- Install Nginx-Naxsi Ubuntu 16.04 Install Nginx-Naxsi on Ubuntu 16.04 Understanding Nginx and Naxsi Nginx is a high-performance web server which can also be used as a reverse proxy or load balancer. Naxsi is a…
- Wordpress Mariadb Nginx On Centos 7 Wordpress Mariadb Nginx On Centos 7 Installing Apache Apache is the most popular web server in the world. It is a powerful, versatile, and free open source software available for…
- Laravel Nginx Config Ubuntu 18 Laravel Nginx Config Ubuntu 18 Introduction Laravel is a powerful web-based MVC (Model-View-Controller) framework used by developers to create web applications, websites and APIs. It is based on the popular…
- Install Wordpress On Ubuntu 18.04 Nginx Install WordPress On Ubuntu 18.04 Nginx Introduction To Ubuntu And Nginx Ubuntu is a popular open-source operating system which has gained immense popularity over the years. It is easy to…
- Install Nginx Di Kali Linux Install Nginx Di Kali Linux Introduction Kali Linux is a well-known operating system specially designed for Penetration Testing and Security Auditing tasks. The operating system is loaded with all the…
- Nginx Wordpress Ubuntu 18.04 Nginx Wordpress Ubuntu 18.04 Introduction to Nginx Nginx is a web server software for hosting websites and applications. It is open-source and highly configurable, making it a popular choice for…
- Install Laravel 5.8 Nginx Php7.3 Install Laravel 5.8 Nginx Php7.3 Overview Installing Laravel 5.8 on a Nginx server running PHP 7.3 can be a tricky task. This tutorial explains how to install the popular open…
- Hhvm Nginx Ubuntu 16.4 HHVM Nginx Ubuntu 16.4 What is HHVM? HHVM, also known as HipHop Virtual Machine, is a virtual machine developed by Facebook to speed up the execution of PHP code. It…
- Instal Nginx Ubuntu 18.04 Installing Nginx on Ubuntu 18.04 What is Nginx? Nginx is a lightweight, open source, high-performance web server designed for serving dynamic and static web content. It is capable of handling…
- Install Postgis Ubuntu 18.04 Nginx Install Postgis Ubuntu 18.04 Nginx What is Postgis? Postgis is a Postgres-based open source geographic information system (GIS) that enables users to store, query, and analyze spatial data stored in…
- Install Webuzo Without Conlicting Nginx Centos 7 Install Webuzo Without Conlicting Nginx Centos 7 What is Nginx? Nginx is an open-source web server that was created and released in 2004. It is known for its speed, stability,…
- Centos 7 Install Nginx Php Mariadb Centos 7 Install Nginx Php Mariadb Installing Centos 7 for Nginx CentOS 7 is one of the most widely used linux distributions for web servers, and it is an ideal…