安装和配置nginx

来源:互联网 发布:怎么修改电脑的端口 编辑:程序博客网 时间:2024/05/28 14:56
<pre name="code" class="sql">web服务器nginx和apache的对比分析yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses* libmcrypt* 
<span style="color: rgb(39, 42, 48); font-family: 'Microsoft Yahei'; line-height: 17px;"> ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx/ --with-http_stub_status_module --with-http_ssl_module</span>配置nginx ./configure --prefix=/usr/local/nginx --with-http_stub_status_module解释: --prefix 为安装路径,--with-为需要安装的模块,具体可以运行./configure --help 查看有效模块./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> optionyum -y install  *pcre*makemake installv-lhb-web01:/root/nginx-1.7.7# /usr/local/nginx/sbin/nginx v-lhb-web01:/root/nginx-1.7.7# v-lhb-web01:/root/nginx-1.7.7# v-lhb-web01:/root/nginx-1.7.7# ps -ef | grep nginxroot     26705     1  0 17:19 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginxnobody   26706 26705  0 17:19 ?        00:00:00 nginx: worker process      root     26708 21330  0 17:19 pts/0    00:00:00 grep nginxv-lhb-web01:/root/nginx-1.7.7# 启用: /usr/sbin/nginx -c /etc/nginx/nginx.conf1.demo:/etc/nginx# /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:2解决:创建nginx用户和组jrhwpt01:/etc# id nginxuid=411(nginx) gid=411(nginx) groups=411(nginx)front-end:/root/nginx-1.7.7# useradd -m -g nginx -s /sbin/nologin  nginx2.demo:/etc/nginx# /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:16文件路径不对:demo:/usr/local/nginx# cd conf/demo:/usr/local/nginx/conf# lsfastcgi.conf          fastcgi_params          koi-utf  mime.types          nginx.conf          scgi_params          uwsgi_params          win-utffastcgi.conf.default  fastcgi_params.default  koi-win  mime.types.default  nginx.conf.default  scgi_params.default  uwsgi_params.defaultdemo:/usr/local/nginx/conf# cp -r * /etc/nginx/cp: overwrite `/etc/nginx/nginx.conf'? ydemo:/etc/nginx# /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf demo:/etc/nginx# 启动正常demo:/etc/nginx# /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf demo:/etc/nginx# ps -ef | grep nginxroot      5213     1  0 15:54 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.confnginx     5214  5213  0 15:54 ?        00:00:00 nginx: worker process                               root      5216  1706  0 15:55 pts/0    00:00:00 grep nginxdemo:/etc/nginx# demo:/etc/nginx# netstat -nap | grep nginxtcp        0      0 0.0.0.0:8001                0.0.0.0:*                   LISTEN      5213/nginx          unix  3      [ ]         STREAM     CONNECTED     19847  5213/nginx          unix  3      [ ]         STREAM     CONNECTED     19846  5213/nginx  http://192.168.32.172:8001/访问报403 Forbidden--------------------------------------------------------------------------------nginx/1.7.71.修改权限:demo:/var/www# chmod -R 777 zjzc-web-frontEndhttp://192.168.32.172:8001/ --正常访问demo:/var/www# ps -ef | grep nginxroot      5280     1  0 16:01 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.confnginx     5281  5280  0 16:01 ?        00:00:00 nginx: worker process                               root      5319  1706  0 16:06 pts/0    00:00:00 grep nginx


                                             
0 0