Centos 7 installs nginx (source code)

Keywords: Nginx yum zlib firewall

Liunx installing nginx (source code)

First step

wget http://nginx.org/download/nginx-1.16.0.tar.gz
  • decompression
tar -zxvf nginx-1.16.0.tar.gz 

install

  • Enter nginx-1.16.0 directory
./configure
  • Here, if the installation fails, report:
./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.
  • Solution
install pcre-devel
yum -y install pcre-devel

//Install zlib-devel
yum install -y zlib-devel

start-up

-Use the following command to view the path of nginx installation

whereis ngnix
  • For example, my nginx is installed in / usr/local/nginx/
  • Entry directory
[root@iZ2ze5lq5zpd6lctghc8x3Z /]# cd /usr/local/nginx/
[root@iZ2ze5lq5zpd6lctghc8x3Z nginx]# ll
total 36
drwx------ 2 nobody root 4096 Jul 11 17:01 client_body_temp
drwxr-xr-x 2 root   root 4096 Jul 11 16:59 conf
drwx------ 2 nobody root 4096 Jul 11 17:01 fastcgi_temp
drwxr-xr-x 2 root   root 4096 Jul 11 16:59 html
drwxr-xr-x 2 root   root 4096 Jul 11 17:01 logs
drwx------ 2 nobody root 4096 Jul 11 17:01 proxy_temp
drwxr-xr-x 2 root   root 4096 Jul 11 16:59 sbin
drwx------ 2 nobody root 4096 Jul 11 17:01 scgi_temp
drwx------ 2 nobody root 4096 Jul 11 17:01 uwsgi_temp

  • In the sbin directory, start nginx
[root@iZ2ze5lq5zpd6lctghc8x3Z nginx]# cd sbin/
[root@iZ2ze5lq5zpd6lctghc8x3Z sbin]# ll
total 3736
-rwxr-xr-x 1 root root 3825176 Jul 11 16:59 nginx
[root@iZ2ze5lq5zpd6lctghc8x3Z sbin]# ./nginx 
[root@iZ2ze5lq5zpd6lctghc8x3Z sbin]# ps -ef | grep nginx
root      4233  4187  0 15:31 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon off; error_log /dev/stderr info;
100       4234  4233  0 15:31 ?        00:00:00 nginx: worker process
root      7476     1  0 17:01 ?        00:00:00 nginx: master process ./nginx
nobody    7477  7476  0 17:01 ?        00:00:00 nginx: worker process
root      7485  3252  0 17:01 pts/1    00:00:00 grep --color=auto nginx

Verify success

  • Local service
127.0.0.1 or localhost
  • Remote access is your IP. If it fails, check whether your port 80 turns on or off the firewall.

nginx is configured in detail according to its own needs, looking forward to the future

Posted by F.Danials on Wed, 30 Oct 2019 12:59:12 -0700