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 In Ubuntu 16.04 Install Nginx In Ubuntu 16.04 Overview of Nginx Nginx (pronounced "engine-x") is an open-source Web server that is designed to provide a balance of flexibility, performance, and scalability. It is…
- Install Wordpress On Nginx Ubuntu Install Wordpress On Nginx Ubuntu Introduction WordPress is a popular open-source blogging platform and content management system (CMS). It is made to be used on the internet, and it is…
- 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…
- Ubuntu Server Postgresql Nginx Php Ubuntu Server Postgresql Nginx Php Introduction Optimizing your server is one of the most important steps you can take when it comes to running a successful website or application. It…
- Install Rapidssl Nginx Ubuntu 18.04 Install RapidSSL with Nginx on Ubuntu 18.04 Step 1: Installing Nginx The first step in setting up RapidSSL with Nginx on Ubuntu 18.04 is to install Nginx itself. This can…
- Bash Install Nginx On Ubuntu How To Install Nginx On Ubuntu What is Nginx? Nginx is a web server that is gaining popularity in the world of web hosting. Nginx is an open source web…
- Install Phpmyadmin On Nginx Ubuntu Install Phpmyadmin On Nginx Ubuntu What Is Phpmyadmin? Phpmyadmin is a free, open source web application written in PHP specifically designed to help manage MySQL databases. It is a powerful…
- How To Install Wordpress On Nginx Centos How To Install Wordpress On Nginx Centos Step 1: Install Nginx server The first step to installing WordPress on Nginx CentOS is to install Nginx server. Nginx is a high-performance…
- Install Nginx Passenger Ubuntu 16.04 Install Nginx Passenger Ubuntu 16.04 Installing Nginx On Ubuntu 16.04 Nginx is an open source web server that can be used to create web and application servers. It is a…
- Install Nginx Latest Ubuntu 16.04 Install Nginx Latest Ubuntu 16.04 What is Nginx? Nginx is a web server. It is also an open source and free software. It was first developed by Igor Sysoev in…
- Install Nginx And Php On Ubuntu Install Nginx And Php On Ubuntu A Comprehensive Tutorial to Install Nginx And Php On Ubuntu Nginx and PHP are two of the most popular web server and scripting language…
- How To Set Rails On Nginx Ubuntu 18.04 How To Set Rails On Nginx Ubuntu 18.04 Step 1: Install Ruby Using RVM The first step for setting up Ruby on Rails on an Ubuntu 18.04 server with Nginx…
- Setup Wordpress With Memcached And Nginx Setup Wordpress With Memcached and Nginx Installing Memcached Memcached is a distributed in-memory caching system used to speed up web applications such as WordPress. It stores data in memory and…
- Kubectl Install Nginx Wordpress Bare Metal Kubectl Install Nginx Wordpress On Bare Metal Introduction To The Process Of Installing Nginx On Bare Metal With the new trend of cloud and automated solutions, it has become easier…
- 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…
- 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…
- Wordpress Permalink Http 404 On Nginx Here We Go. WordPress Permalink Http 404 On Nginx What is WordPress Permalink? WordPress Permalinks, also known as permanent links, are URLs (Uniform Resource Locators) that are used to access…
- How To Ubuntu 16.04 Multiple Php Nginx How to Ubuntu 16.04 Multiple PHP Nginx Ubuntu 16.04 is a robust operating system that is commonly used for web application development. This operating system uses Nginx as the web…
- Replace Apache To Nginx Ubuntu 18 Replace Apache To Nginx Ubuntu 18 Installing Nginx Ubuntu 18 uses Nginx as its default web server, and it is pre-installed. However, if you want to use a fresh version…
- How Use Nginx Mysql Ubuntu How to Use Nginx, MySQL and Ubuntu What is Nginx? Nginx is an open source web server and reverse proxy software written by Igor Sysoev. It is a popular choice…
- Install Laravel Ubuntu 16.04 With Nginx Web Server Install Laravel Ubuntu 16.04 With Nginx Web Server Introduction Laravel is one of the most popular expressive, elegant, and robust PHP frameworks available today. It is an open source framework…
- Nginx Always Displaying Default Page In Ubuntu Nginx Always Displaying Default Page In Ubuntu Introduction Ubuntu is one of the most popular Linux distributions and an immensely powerful and versatile operating system. It has a great package…
- Wordpress Nginx Ubuntu 18.04 Wordpress Nginx Ubuntu 18.04 Overview WordPress is a popular web software used by millions of people around the world. It allows users to easily create and manage websites without the…
- How To Install Wordpress On Nginx How To Install Wordpress On Nginx Introduction If you’re looking to start your own website or blog, probably the easiest and most popular platform to choose is WordPress. WordPress is…
- Wordpress Nginx File Not Found Wordpress Nginx File Not Found What is Nginx? Nginx is a powerful open-source web server used to host web content and applications. It is designed to be fast, reliable, and…
- Tutorial Install Nginx Di Ubuntu Vps Tutorial Install Nginx Di Ubuntu Vps Step 1: Install Nginx The first step to install nginx in your Ubuntu VPS is to install the nginx package. To do this, use…
- Cara Install Nginx Ubuntu 14.04 Cara Install Nginx Ubuntu 14.04 Step 1: Update the Software Packages The first step in installing Nginx is to update the software packages in Ubuntu 14.04. This can be done…
- 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,…
- 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 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…