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:
- 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…
- 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…
- 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…
- 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…
- Completely Uninstall Phpmyadmin On Nginx Ubuntu 18.04 Completely Uninstall PhpMyAdmin On NGINX Ubuntu 18.04 Introduction PhpMyAdmin is a very popular web-based graphical tool for managing MySQL databases in the Ubuntu operating system. It is used by web…
- 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…
- 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 Odoo 11 Nginx Ubuntu 16 Install Odoo 11 Nginx Ubuntu 16 What is Odoo 11 Nginx? Odoo 11 Nginx is an open source software package designed to facilitate secure and reliable web development. It is…
- 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.…
- 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…
- How To Install Nginx On Ubuntu 18.04 How To Install Nginx on Ubuntu 18.04 Introduction Nginx is a popular open-source web server and reverse proxy software that’s used by millions of websites. It’s the most widely used…
- 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…
- How To Enable Php Exec In Nginx Ubuntu 16.04 How To Enable Php Exec In Nginx Ubuntu 16.04 What Is Php Exec In Nginx PHP-FPM (also known as FastCGI Process Manager) is an alternative implementation of PHP that provides…
- Lets Encrypt Nginx Ubuntu 14.04 With Nginx Conf Custom Let's Encrypt Nginx Ubuntu 14.04 with Nginx Conf Custom Introduction to Nginx Conf Custom Nginx Conf Custom is an open source solution for hosting web applications on Ubuntu 14.04. It…
- Install Nginx Php Mysql Ssl & Wordpress On Ubuntu 18.04 Install Nginx Php Mysql Ssl & Wordpress On Ubuntu 18.04 What is Nginx, Php, Mysql, SSL and Wordpress? Nginx is a high-performance web server that is widely used to serve…
- Install Php5 Nginx Ubuntu 18.04 Install PHP5 Nginx Ubuntu 18.04 Understanding The Basics of Nginx and PHP Before we learn how to install Nginx and PHP on Ubuntu 18.04, it’s important to understand the basic…
- Check Nginx Version Centos 7 Check Nginx Version Centos 7 1. What is Nginx? Nginx is an open source web server software created by Igor Sysoev in 2002 and is widely used for powering the…
- Webdav Nginx Ubuntu 16.04 Webdav Nginx Ubuntu 16.04 Introduction to Webdav with Nginx in Ubuntu 16.04 The ever-evolving world of the internet has given us a powerful platform to share information, media, and files…
- Install Php Nginx Ubuntu 12.04 Install Php Nginx Ubuntu 12.04 Introduction Welcome to our guide on How to install PHP, Nginx & MySQL on Ubuntu 12.04 LTS. This guide should work on other Linux VPS…
- Digitalocean Install Nginx Ubuntu 18.04 Digitalocean Install Nginx Ubuntu 18.04 Introducing DigitalOcean and Nginx DigitalOcean is a virtual cloud server provider, allowing users to spin up virtual servers located in various geographical locations throughout the…
- Install Nginx In Ubuntu 16.04 Terminal Install Nginx On Ubuntu 16.04 Terminal Nginx (pronounced "engine x") is a lightweight web server that is becoming the most popular way to serve content on the web. It is…
- Error Nginx When Installing Certbot Ubuntu Error Nginx When Installing Certbot Ubuntu What is Nginx? Nginx is a web server software often used to serve web pages. It is known as a high-performance web server and…
- 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…
- Install Nginx Mysql Phpmyadmin Ubuntu Install Nginx Mysql Phpmyadmin Ubuntu 1. Introduction In today's tutorial, we will show you how to install Nginx, MySQL, and phpMyAdmin on Ubuntu 20.04. Nginx is an open source web…
- 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…
- 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.…
- 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…
- Install Php Nginx Mysql Ubuntu 18.04 Install Php Nginx Mysql Ubuntu 18.04 What is PHP, Nginx, and MySQL PHP is a popular and powerful scripting language that can be used to create dynamic web pages, web…
- Ubuntu 16.04 Nginx Ipv6 Ubuntu 16.04 Nginx Ipv6 What is Ubuntu 16.04? Ubuntu 16.04 is a version of the Ubuntu Linux operating system for computers and servers. Ubuntu has been around since 2004, and…