I won’t go into the relevant introduction of nginx. Since you choose nginx as your web server, you must have different knowledge and understanding of nginx server. Next, I will install it directly.
I am using the centos7.3 64-bit core version system. Before installing and configuring nginx, you must install the nginx dependency package. Please see the production chapter of Centos 7 compilation and installation of php7.1, and install the dependency package provided at the beginning of the article. This dependent component package is suitable for any version of Nginx.
Create new web users and groups
$ /usr/sbin/groupadd www $ /usr/sbin/useradd -g www www $ ulimit -SHn 65535 //设置linux高负载参数
There are two versions when downloading Nginx: development version and stable version. If it is used for production, download the stable version, http://nginx.org/en/download.html (it is best to download the latest version of the stable version, so there will be bug fixes and new features) I downloaded the latest version nginx-1.13.5.
$ cd /tmp $ wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz $ tar zxvf openssl-1.1.0e.tar.gz $ wget https://nginx.org/download/nginx-1.13.5.tar.gz $ tar zxvf nginx-1.13.5.tar.gz $ cd nginx-1.13.5
You may notice that some document tutorials do not assign so many modules when installing nginx (it looks very long), and some do not even assign modules and users. In fact, modules are assigned according to their own needs. If you want If there is no trouble in the future, then just follow the module assignment below. In fact, this is considered all-in-one. Otherwise, you will have to recompile it later if you need it. It is not very troublesome, but it is not easy either. As for whether to assign user groups, I will definitely let you do so. This is related to the availability, security and stability of the nginx configuration.
$ ./configure \ --prefix=/usr/local/nginx \ --user=www \ --group=www \ --with-pcre \ --with-openssl=/tmp/openssl-1.1.0e \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-http_auth_request_module \ --with-http_image_filter_module \ --with-http_slice_module \ --with-mail \ --with-threads \ --with-file-aio \ --with-stream \ --with-mail_ssl_module \ --with-stream_ssl_module \
$ make -j8 && make install //编译并安装
After the installation is completed, it needs to be turned on automatically. Otherwise, it needs to be started manually every time, which would be too troublesome.
$ vim /usr/lib/systemd/system/nginx.service [Unit] Description=The nginx HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/bin/kill -s HUP /usr/local/nginx/logs/nginx.pid ExecStop=/bin/kill -s QUIT /usr/local/nginx/logs/nginx.pid PrivateTmp=true [Install] WantedBy=multi-user.target 保存并退出。
$ systemctl enable nginx.service $ systemctl restart nginx.service
$ firewall-cmd --zone=public --add-port=80/tcp --permanent $ firewall-cmd --reload
$ ss -ntlp
You can see that the nginx process is running. At this point, the nginx installation is complete. You may still have questions about how nginx parses and supports PHP programs. Don't panic, I will write about it in the next article.
The above is the detailed content of Original: Centos 7 source code compilation and installation of Nginx 1.13. For more information, please follow other related articles on the PHP Chinese website!