centos7下编译安装nginx

下载:

wget http://nginx.org/download/nginx-1.10.1.tar.gz

解压

tar -zxvf nginx-1.10.1.tar.gz

安装编译环境

 yum -y install gcc gcc-c++ openssl openssl-devel perl-devel perl-ExtUtils-Embed

编译运行

编译安装

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_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-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6

make

make install

测试

使用下面命令:

nginx -v

说明安装完成。

运行

在上面的命令行中存在–sbin-path=/usr/sbin/nginx这一句,说明nginx的启动目录在这里,在命令行中执行:

/usr/sbin/nginx

可能会出现下面提示:

nginx: [emerg] getpwnam("nginx") failed

解决方法如下:

解决方法1:

  在nginx.conf中 把user nobody的注释去掉既可

解决方法2:

  错误的原因是没有创建www这个用户,应该在服务器系统中添加www用户组和用户www,如下命令:
#/usr/sbin/groupadd -f www
#/usr/sbin/useradd -g www www

解决上面之后还可能有下面问题:

nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (2: No such file or directory)

解决方法就是自己新建目录就OK。

解决了以上问题在执行

运行:

/usr/sbin/nginx

就可以成功启动了。
这里写图片描述
停止方式:

/usr/sbin/nginx -s stop

参考:http://www.tuicool.com/articles/BFJz6zN

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值