1. Download the installation package from the official website http://nginx.org/en/download.html, select the version suitable for Linux, here choose the latest version, download it locally and upload it to the server or directly download it with the wget command under centos. Switch to the /usr/local directory and download the software package # cd /usr/local # wget http://nginx.org/download/nginx-1.11.5.tar.gz 2. Install nginx First execute the following command to install the nginx dependency library. If the dependency library is missing, the installation may fail. For details, please refer to the error message at the end of the article. # yum install gcc-c++ # yum install pcre # yum install pcre-devel # yum install zlib # yum install zlib-devel # yum install openssl # yum install openssl-devel Unzip the installation package # tar -zxvf nginx-1.11.5.tar.gz nginx is unzipped to the /usr/local/nginx-1.11.5 directory (do not unzip the compressed package to the /usr/local/nginx directory, or rename the unzipped directory to nginx, because nginx will be installed to the /usr/local/nginx directory by default), switch to the nginx-1.11.5/ directory # cd /usr/local/nginx-1.11.5/ Execute # ./configure # ./configure This operation will detect the current system environment to ensure that nginx can be successfully installed. After performing this operation, the following prompts may appear: checking for OS + Linux 3.10.0-123.el7.x86_64 x86_64 checking for C compiler ... not found ./configure: error: C compiler cc is not found If the above error message appears, execute yum install gcc-c++ to install gcc. ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option. If the above prompt appears, it means that the PCRE library is missing ./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option. If the above prompt appears, it means that the zlib library is missing If the ./configure: error prompt does not appear, it means that nginx can be installed in the current environment. Execute make and make install to compile nginx. # make # make install If there is no error, it means that nginx has been successfully installed. The default installation location is /usr/local/nginx. The previous /usr/local/nginx-1.11.5/ can be deleted. If the message cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file appears, it may be that you have unzipped the installation package to the /usr/local/nginx directory. The solution is to rename the directory to another name and then execute make, make install. 3. Configure nginx to start up Switch to the /lib/systemd/system/ directory and create the nginx.service file vim nginx.service # cd /lib/systemd/system/ # vim nginx.service The file contents are as follows: [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx reload ExecStop=/usr/local/nginx/sbin/nginx quit PrivateTmp=true [Install] WantedBy=multi-user.target Exit and save the file, execute systemctl enable nginx.service to start nginx at boot # systemctl enable nginx.service systemctl start nginx.service starts nginx systemctl stop nginx.service ends nginx systemctl restart nginx.service restart nginx 4. Verify whether the installation is successful Enter http://server IP/ If you can see the nginx interface, it means the installation is successful The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of Nest.js environment variable configuration and serialization
>>: A brief discussion on MySQL index design principles and the differences between common indexes
MySQL Bin log data recovery: accidentally delete ...
Table of contents 1. MySQL replication process 2....
Today I will use the server nginx, and I also nee...
mysql query data from one table and insert it int...
Linux: Linux version 3.10.0-123.9.3.el7.x86_64 Ng...
Source code preview: https://github.com/jdf2e/nut...
The network configuration of Host Only+NAT mode u...
There are two ways: 1. Service method Check the f...
Vue2+elementui's hover prompts are divided in...
Table of contents HTTP hijacking, DNS hijacking a...
Original code: center.html : <!DOCTYPE html>...
When multiple images are introduced into a page, ...
The data type of MySQL is datetime. The data stor...
Table of contents Preface 1. Introduction to one-...
Preface The location in the server block in the N...