{"id":146702,"date":"2020-12-29T22:44:14","date_gmt":"2020-12-29T22:44:14","guid":{"rendered":"https:\/\/onet.com.vn\/how-to-install-and-configure-a-nginx-server-for-the-first-time.html"},"modified":"2020-12-29T22:44:14","modified_gmt":"2020-12-29T22:44:14","slug":"how-to-install-and-configure-a-nginx-server-for-the-first-time","status":"publish","type":"post","link":"https:\/\/onet.com.vn\/how-to-install-and-configure-a-nginx-server-for-the-first-time\/","title":{"rendered":"How to Install, And Configure a Nginx Server For the First Time"},"content":{"rendered":"\n
Being asynchronous, ability to handle millions of users without slowing down the server makes it the number one choice in many enterprises to deploy their systems. This guide demonstrates how to install, and configure Nginx web servers with ease. The guide uses Ubuntu 18.04 as the version because it\u2019s LTS; hence it has a long-term support which is required in a production environment. Installing and configuring a Nginx web server are relatively easy, but it involves a number of steps.<\/p>\n
These instructions were written for Ubuntu 18.04 LTS version, and thus it should not be used in a different Linux flavour unless the same commands work over there as well. It\u2019s encouraged to install Nginx in a regular user account with sudo permission in order to the mitigate security risk. However, this article doesn\u2019t demonstrate how to create a user account as it\u2019s out of its scope.<\/p>\n
http:\/\/IPAddress<\/a><\/p>\n <\/a><\/p>\n <\/a><\/p>\n Installing Nginx is simple as described above, but configuration requires more effort, and it also depends on the requirements and environment of the server. This guide demonstrates how to configure a nginx web server for one domain, how to adjust basic settings, how to set up SSL\/TLS, which is required by Google to improve the rank of the web site, and finally what commands are involved in setting up a Nginx server.<\/p>\n The configuration file contains a few important lines as seen in the following code snippet.<\/p>\n\n
\n
sudo<\/span> chmod<\/span> -R<\/span> 755<\/span> \/<\/span>var\/<\/span>www\/<\/span>example.com<\/div>\n<\/div>\nConfiguration<\/h3>\n
\n
\n
\n
listen 80<\/span> default_server;<\/span>
listen [<\/span>::<\/span>]<\/span>:<\/span>80<\/span> default_server;<\/span>
server_name _;<\/span>
root\u00a0\u00a0 \/<\/span>var\/<\/span>www\/<\/span>html\/;<\/span>
index index.php<\/span> index.html<\/span> index.htm<\/span>;<\/span>
location \/<\/span> {<\/span>
\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try_files $uri $uri\/<\/span> =<\/span>404<\/span>;<\/span>
\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span>
}<\/span><\/div>\n<\/div>\n\n
\n
\n
\n
-d<\/span> www.domain.extension<\/div>\n<\/div>\n\n
\n