-group=*name* 设置nginx工作进程的用户组。安装完成后,可以随时更改的名称在nginx.conf配置文件中 使用的 user指令。默认的为非特权用户。
--with-select_module
--without-select_module 启用或禁用构建一个模块来允许服务器使用select()方法。该模块将自动建立,如果平台不支持的kqueue,epoll,rtsig或/dev/poll。
--with-poll_module
--without-poll_module
启用或禁用构建一个模块来允许服务器使用poll()方法。该模块将自动建立,如果平台不支持的kqueue,epoll,rtsig或/dev/poll。
--without-http_gzip_module
— 不编译压缩的HTTP服务器的响应模块。编译并运行此模块需要zlib库。
--without-http_rewrite_module
不编译重写模块。编译并运行此模块需要PCRE库支持。
--without-http_proxy_module
— 不编译http_proxy模块。
--with-http_ssl_module
— 使用https协议模块。默认情况下,该模块没有被构建。建立并运行此模块的OpenSSL库是必需的。
--with-pcre=*path*
— 设置PCRE库的源码路径。PCRE库的源码(版本4.4 - 8.30)需要从PCRE网站下载并解压。其余的工作是Nginx的./ configure和make来完成。正则表达式使用在location指令和 ngx_http_rewrite_module 模块中。
--with-pcre-jit
—编译PCRE包含“just-in-time compilation”(1.1.12中, pcre_jit指令)。
--with-zlib=*path*
—设置的zlib库的源码路径。要下载从 zlib(版本1.1.3 - 1.2.5)的并解压。其余的工作是Nginx的./ configure和make完成。ngx_http_gzip_module模块需要使用zlib 。
--with-cc-opt=*parameters*
— 设置额外的参数将被添加到CFLAGS变量。例如,当你在FreeBSD上使用PCRE库时需要使用:--with-cc-opt="-I /usr/local/include。
.如需要需要增加 select()支持的文件数量
:--with-cc-opt="-D FD_SETSIZE=2048".
--with-ld-opt=*parameters*
—设置附加的参数,将用于在链接期间。例如,当在FreeBSD下使用该系统的PCRE库,应指定:--with-ld-opt="-L /usr/local/lib".
安装完成后,按照安装的参数,安装的启动目录在/usr/local/nginx
[root@localhost nginx]# ls -l
总用量 76
drwxr-xr-x. 2 root root 4096 9月 8 09:46 conf
-rw-r--r--. 1 root root 1077 9月 8 10:34 fastcgi.conf
-rw-r--r--. 1 root root 1077 9月 8 10:34 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 9月 8 10:34 fastcgi_params
-rw-r--r--. 1 root root 1007 9月 8 10:34 fastcgi_params.default
drwxr-xr-x. 2 root root 40 9月 8 09:46 html
-rw-r--r--. 1 root root 2837 9月 8 10:34 koi-utf
-rw-r--r--. 1 root root 2223 9月 8 10:34 koi-win
drwxr-xr-x. 2 root root 41 9月 8 10:37 logs
-rw-r--r--. 1 root root 5231 9月 8 10:34 mime.types
-rw-r--r--. 1 root root 5231 9月 8 10:34 mime.types.default
-rw-r--r--. 1 root root 2656 9月 8 10:34 nginx.conf
-rw-r--r--. 1 root root 2656 9月 8 10:34 nginx.conf.default
-rw-r--r--. 1 root root 6 9月 8 10:37 nginx.pid
drwxr-xr-x. 2 root root 36 9月 8 10:34 sbin
-rw-r--r--. 1 root root 636 9月 8 10:34 scgi_params
-rw-r--r--. 1 root root 636 9月 8 10:34 scgi_params.default
-rw-r--r--. 1 root root 664 9月 8 10:34 uwsgi_params
-rw-r--r--. 1 root root 664 9月 8 10:34 uwsgi_params.default
-rw-r--r--. 1 root root 3610 9月 8 10:34 win-utf
[root@localhost nginx]# pwd
/usr/local/nginx
启动Nginx服务:
由于CentOS-7防火墙不开发端口,所以在本地测试中,可以选择关闭防火墙或者允许开发80端口
CentOS防火墙
# systemctl status firewalld ==> 防火墙状态
# systemctl start firewalld ==> 开启防火墙
# systemctl stop firewalld ==> 关闭防火墙
# systemctl restart firewalld ==> 重启防火墙
# firewall-cmd --reload ==> 防火墙重载
# firewall-cmd --permanent --zone=public --add-port=80/tcp
permanent: 永久有效
zone:作用域
--add-port=80/tcp:添加-端口=端口/通信协议
开放端口或关闭防火墙后就可以启动nginx服务
服务启动
[root@localhost nginx]# netstat -ano | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN off (0.00/0/0)
unix 3 [ ] STREAM CONNECTED 80900
unix 3 [ ] STREAM CONNECTED 80899
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Add