VM下,装centos7系统,配置nginx的问题

一、流程

1.先安装nginx依赖的包

  (1)yum install gcc-c++ 

  (2)yum install -y pcre pcre-devel

  (3)yum install -y zlib zlib-devel

  (4)yum install -y openssl openssl-devel

2.把nginx的源码上传到linux系统

3.把压缩包解压缩。

4.进行configure。

./configure

--prefix=/usr/local/nginx

--pid-path=/var/run/nginx/nginx.pid

--lock-path=/var/lock/nginx.lock

--error-log-path=/var/log/nginx/error.log

--http-log-path=/var/log/nginx/access.log

--with-http_gzip_static_module

--http-client-body-temp-path=/var/temp/nginx/client

--http-proxy-temp-path=/var/temp/nginx/proxy

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi

--http-scgi-temp-path=/var/temp/nginx/scgi

注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录

5:make

6:make install

二、问题

1.nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or  directory)

  解决1:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  解决2:删了重装

2.VM中的centos7中执行ifconfig没发现eth0,但是却有ens33

  发现使用ens33,也不影响,我把VM中网络适配器设置为了

  

3.在自己的笔记本电脑上访问不了安装在centos7下的nginx

  解决办法:关闭centos的防火墙,

  直接关闭防火墙

  systemctl stop firewalld.service #停止firewall

  systemctl disable firewalld.service #禁止firewall开机启动

其命令行为systemctl stop firewalld.service

4.在浏览器访问url 404的问题

在nginx.conf文件里加一条:user root; 就可以解决

原文地址:https://www.cnblogs.com/fengyuzhongdexiongying/p/6874142.html