Install Nginx Ubuntu Server 14.04
Method 1: Installing Nginx from the Ubuntu Repositories
Nginx is available for installation from the default Ubuntu repositories using the apt package manager tool. If you are using an Ubuntu 14.04 server instance, using ssh to connect to the server as the root user and run the following command to update the apt package index:
apt-get update
Once the package index is updated next, install Nginx by typing:
apt-get install nginx
Once the installation is completed, check the version by typing:
nginx -v
This will print out the version number of the Nginx server running in your system, for example:
nginx version: nginx/1.4.6
You have now installed nginx from the Ubuntu repositories.
Method 2: Installing Nginx from the Source
Another method of installing nginx is to compile it from the source code. To start, you need to install some basic dependencies such as the compiler, libc headers and other libraries.
apt-get install build-essential
apt-get install libpcre3 libpcre3-dev libssl-dev zlib1g-dev
Once the dependencies are installed, download the source files of nginx from the official website:
wget http://nginx.org/download/nginx-1.4.6.tar.gz
Extract the archive by running the command:
tar -xzvf nginx-1.4.6.tar.gz
Move to the extracted directory and start the installation process by running the command:
cd nginx-1.4.6
./configure --sbin-path=/usr/sbin
make
make install
The configure command marks the installation prefix. The make command builds the application from the source files specified in the Makefile. And finally, the make install command installs the binary of the compiled application.
Once the installation is completed, check the version of Nginx:
nginx -v
You have now installed nginx from the source.
Configuring Nginx
Before starting Nginx, you need to configure it with the custom settings which are located in the Nginx configuration file, which is usually located at /etc/nginx/nginx.conf. These settings include server name, ports, and other configuration directives.
Once the configuration is done, start the web server by running the command:
service nginx start
You can now check the status of Nginx with the command:
service nginx status
Alternatively, you can also check if the web server is running correctly by connecting to it with a web browser.
Testing Nginx
Once the web server is running correctly, it’s time to test it to make sure it is working correctly. To do this, you can create a simple PHP script and place it in the web server document root (/var/www/html by default).
Save the following code as info.php in the document root:
echo phpinfo();
?>
Now, open a web browser and type in the address of your server, in this case it is http://localhost/info.php. You should get the output of phpinfo. This indicates that your web server is working correctly.
Securing Nginx
By default, Nginx comes with a basic configuration that should get you started. But there are some configuration settings which you must consider before deploying Nginx in production.
The first thing to consider is to modify the configuration file and change the default port of the web server to a non-standard port, which is less known to hackers. This will make it difficult for attackers to guess the port number of the web server and make it harder for them to gain access.
Another important security setting is to enable the ssl module and enable HTTPS for your web server, so that all communication between the server and the user is encrypted. To enable the ssl module, edit the /etc/nginx/nginx.conf file and add the following line:
ssl on;
Now, you need to generate a self-signed certificate and key pair, which you can do by running the following command:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
You will be prompted to enter some information which will be used for generating the certificate. You can skip all of these entries and just press Enter.
Once the certificate and key is generated, you need to configure Nginx to use the certificate and start accepting HTTPS connections. To do this, edit the /etc/nginx/nginx.conf file and add the following lines:
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
Save the file and restart Nginx for the changes to take effect.
Conclusion
In this article, we have learned how to install and configure Nginx on an Ubuntu 14.04 server instance. We have also covered some basic security configurations to secure the web server. With these configurations, you should be able to deploy a secure and reliable web server in your environment.
FAQs
Q. Is Nginx a web server?
A. Yes, Nginx is a web server.
Q. What version of Nginx is available in the Ubuntu 14.04 repositories?
A. Nginx version 1.4.6 is available in the Ubuntu 14.04 repositories.
Q. How do I check the version of Nginx installed in my system?
A.You can check the version of Nginx by running the command:
nginx -v
Q. How do I configure Nginx to use HTTPS?
A.You need to generate a self-signed certificate and key pair and configure Nginx to use the certificate. Once the certificate and key is generated, edit the nginx.conf file and add the following lines:
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
Save the file and restart Nginx for the changes to take effect.
Thank you for reading this article. Please read other articles on our website for more information.
Related Posts:
- How To Install Nginx On Linux Ubuntu How To Install Nginx On Linux Ubuntu What is Nginx? Nginx is a lightweight web server that is widely used for its ability to handle requests efficiently and quickly. It…
- Install Nginx On Mac Without Brew Install Nginx On Mac Without Brew What Is Nginx? Nginx is an open-source web server that is used for hosting websites and applications. It is highly customizable and can be…
- 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…
- 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…
- Install Pdo_Mysql Ubuntu Nginx Install Pdo_Mysql Ubuntu Nginx What is Pdo_Mysql? PDO_Mysql is a driver for the PHP Data Objects (PDO) extension that provides a database abstraction layer for working with MySQL databases.PDO_Mysql provides…
- 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…
- Install Wordpress On Ubuntu Vps On Nginx Install Wordpress On Ubuntu VPS On Nginx What is WordPress? WordPress is an open-source, content management system (CMS) top-tier overall that is used to create powerful online presence. It powers…
- 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…
- 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…
- How To Install Cachet Nginx How To Install Cachet Nginx Overview Cachet is an open-source monitoring platform that is widely used by web developers, DevOps engineers, and system administrators for monitoring the performance of a…
- Apt-Get Install Nginx Php Mysql Apt-Get Install Nginx Php Mysql What is Apt-Get? Apt-Get is a powerful and innovative command line tool used by Linux-based operating systems such as Debian, Ubuntu, Linux Mint and others.…
- 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…
- 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…
- 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 Nginx Ubuntu How To Install Nginx Ubuntu What is Nginx? Nginx is an open-source web server, reverse proxy, load balancer, and HTTP cache solution with a strong focus on speed and performance.…
- How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts Step 1 — Installing Nginx The first step in installing Nginx and MariaDB 10 on Ubuntu 16.04 is installing Nginx.…
- Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
- Setting Web Server Nginx Wordpress 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…
- Install Web Server Nginx Centos 7 Install Web Server Nginx Centos 7 Introduction Are you looking for a way to set up a web server on your Linux-based system? If so, then installing Nginx on CentOS…
- Error Install Nginx On Ubuntu Error Install Nginx On Ubuntu What is Nginx? Nginx is a web server software used to host web applications. It is open source software developed by the open source community.…
- 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 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…
- Install Laravel 5.1 Ubuntu 16.04 Nginx Install Laravel 5.1 on Ubuntu 16.04 Nginx Introduction Laravel is a free, open-source PHP web application framework that is highly popular with modern web developers. It leverages an expressive and…
- Nginx Command Not Found Ubuntu Nginx Command Not Found Ubuntu What is Nginx? Nginx (pronounced as Engine X) is an open source web server created to handle high traffic network applications, replacing traditional web servers…
- Install Nginx Phpmyadmin Ubuntu 18.04 Install Nginx Phpmyadmin Ubuntu 18.04 Introduction to Nginx, PHP, and Ubuntu Nginx is an open-source, high-performance web server written in C and used to serve static and dynamic webpages. It…
- Nginx Php 5.6 Module Ubuntu 16.04 Nginx Php 5.6 Module Ubuntu 16.04 Overview of Nginx Nginx is a powerful web server that is used to serve both static and dynamic web content. It has become increasingly…
- Docker Install Nginx Mysql Php Docker Install Nginx Mysql Php What is Docker? Docker is an open-source platform for automating the deployment of applications as lightweight, portable, and self-sufficient containers. It bundles applications and all…
- 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…
- Letsencrypt Nginx Ubuntu 16.04 Let’s Encrypt Nginx on Ubuntu 16.04 What is Let’s Encrypt? Let’s Encrypt is an open source Certificate Authority (CA) for issuing free SSL/TLS certificates. SSL/TLS certificates are used to encrypt…
- How To Install Nginx In Ubuntu How To Install Nginx In Ubuntu Introduction to Nginx Nginx is a very powerful web server for hosting websites and applications. It is a fast and reliable server, and is…