[Guide] Install NGINX in Ubuntu server

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
You can find more information about NGINX in the official website.

Install NGINX

The installation of NGINX itself is very simple. The “tricky” part is the configuration because you can configure it in very different ways, depending by your necessities.
# sudo apt-get update
# sudo apt-get install nginx

When the installation is complete, check if NGINX is active: # systemctl status nginx

Install extensions

NGINX has some useful extensions, in this guide I’ll show you how to install and use the php extension.

# sudo apt-get install php-fpm php-mysql

# sudo apt-get install php7.0-json php7.0-curl php7.0-imap php7.0-mcrypt php7.0-mcrypt php7.0-xmlrpc php7.0-zip php7.0-zip php7.0-pgsql php7.0-opcache php7.0-cli php7.0-gmp php7.0-fpm php7.0-gd php7.0-xml php7.0-ldap php7.0-intl

Open the PHP Conf: # sudo nano /etc/php/7.0/fpm/php.ini …
… and edit the line: cgi.fix_pathinfo=0

Then, restart php: # sudo systemctl restart php7.0-fpm
… and restart NGINX: # sudo systemctl restart nginx

Note: If you have a firewall enabled, remember to “open” the ports 80/443 for http/https services.

Useful notes for NGINX

Start NGINX: # sudo systemctl start nginx
Stop NGINX: # sudo systemctl stop nginx
Restart NGINX (Stop + Start): # sudo systemctl restart nginx

Reload configurations: # sudo systemctl reload nginx
Disable start on system boot: # sudo systemctl disable nginx
Re-Enable start on system boot: # sudo systemctl enable nginx

User and group www-data
Config location: /etc/nginx/nginx.conf
Site Available // Enabled location: /etc/nginx/sites-available and /etc/nginx/sites-enabled/

For WordPress (permalink):
location / {
try_files $uri $uri/ /index.php?$args;
}

Leave us your feedback !

Add a comment

*Please complete all fields correctly

Related Blogs

Posted by misterioso | January 6, 2018
[Guide] Install Pure-FTPd in Ubuntu server
Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn’t provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers...
Posted by misterioso | January 5, 2018
[Guide] Install GitLab in Ubuntu server
GitLab is a web-based Git repository manager with some useful tools like board, wiki, issue tracking,… The community edition comes with an open source license and this platform is developed by GitLab Inc....