Because I have been tinkering with Linux recently, I wanted to install a new version of nginx. I looked for a tutorial but couldn't find the corresponding one. After a little tinkering, I finally successfully installed the latest version. The server environment is centos, the following are the detailed steps: Install necessary dependency plugins yum install -y gcc gcc-c++ pcre \ pcre-devel zlib zlib-devel openssl openssl-devel wget Create a folder and switch to it mkdir /customer && cd /customer Download the installation package (if you want to install other versions, you can go to the official website link below and select the link of other versions to copy and replace) wget https://nginx.org/download/nginx-1.16.0.tar.gz Unzip and install tar zxvf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure --prefix=/usr/local/nginx make && make install Adding global commands ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx Test the installation As shown below, the installation is successful: Verify that the service is started successfully netstat -ntlp | grep nginx as follows: Add nginx service vim /lib/systemd/system/nginx.service Insert the following into: [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target Start nginx as a service pkill nginx systemctl start nginx Check whether the service is started systemctl status nginx netstat -ntlp | grep nginx Configure nginx service to start automatically at boot systemctl enable nginx Now the installation is complete, the configuration file is: vim /usr/local/nginx/conf/nginx.conf Optional: The version number of nginx is turned on by default and can be viewed in the default error page and http response header. Different versions, especially lower versions of nginx, may have vulnerabilities, so if you don't want others to obtain the version number, you can choose to hide the version number. Hide nginx version number cd /usr/local/nginx/conf vim nginx.conf Change the "server_tokens" in the nginx.conf file to "off": http { ... server_tokens off; ... } Modify fastcgi.conf again Modify the following line fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; # Change to: fastcgi_param SERVER_SOFTWARE nginx; Restart nginx systemctl restart nginx Hide version number completed Summarize The above is a detailed tutorial on how to install Nginx 1.16.0 under Linux. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time! You may also be interested in:
|
<<: The use and difference between JavaScript pseudo-array and array
>>: A brief discussion of 3 new features worth noting in TypeScript 3.7
The company's business scenario requires the ...
The following installations all use the ~/ direct...
Many of my friends may encounter a problem and do...
1. Download Download mysql-5.7.19-linux-glibc2.12...
Preface: During database operation and maintenanc...
Download source code git clone https://github.com...
Preface If you frequently access many different r...
CSS naming rules header: header Content: content/c...
There are two types of html tags, inline elements...
Preface Most of our MySQL online environments use...
1. In addition to the default port 8080, we try t...
What is a Port? The ports we usually refer to are...
Library Management Create a library create databa...
1. Caches - Query Cache The following figure is p...
I encountered a problem today: Can I use the as a...