CentOS 7中Nginx1

复制代码

如果这个下载太慢可以在这里下载http://nginx.org/download/nginx-1.9.5.tar.gz 下载完后yum -y intall lrzsz 装好上传工具
然后用rz上传到服务器

然后解压文件.

  1. tar zxvf nginx-1.9.5.tar.gz

复制代码

进入 nginx1.9.5的源码  如果想改版本号 可以进入源码目录
src/core/nginx.h
更改

  1. cd nginx-1.9.5/

复制代码

创建一个nginx目录用来存放运行的临时文件夹

  1. mkdir -p /var/cache/nginx

复制代码

开始configure

  1. ./configure \
  2. –prefix=/usr/local/nginx \
  3. –sbin-path=/usr/sbin/nginx \
  4. –conf-path=/etc/nginx/nginx.conf \
  5. –error-log-path=/var/log/nginx/error.log \
  6. –http-log-path=/var/log/nginx/access.log \
  7. –pid-path=/var/run/nginx.pid \
  8. –lock-path=/var/run/nginx.lock \
  9. –http-client-body-temp-path=/var/cache/nginx/client_temp \
  10. –http-proxy-temp-path=/var/cache/nginx/proxy_temp \
  11. –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
  12. –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
  13. –http-scgi-temp-path=/var/cache/nginx/scgi_temp \
  14. –user=nobody \
  15. –group=nobody \
  16. –with-pcre \
  17. –with-http_v2_module \
  18. –with-http_ssl_module \
  19. –with-http_realip_module \
  20. –with-http_addition_module \
  21. –with-http_sub_module \
  22. –with-http_dav_module \
  23. –with-http_flv_module \
  24. –with-http_mp4_module \
  25. –with-http_gunzip_module \
  26. –with-http_gzip_static_module \
  27. –with-http_random_index_module \
  28. –with-http_secure_link_module \
  29. –with-http_stub_status_module \
  30. –with-http_auth_request_module \
  31. –with-mail \
  32. –with-mail_ssl_module \
  33. –with-file-aio \
  34. –with-ipv6 \
  35. –with-http_v2_module \
  36. –with-threads \
  37. –with-stream \
  38. –with-stream_ssl_module

复制代码

接着 编译

  1. make

复制代码

安装

  1. make install

复制代码

启动nginx

  1. /usr/sbin/nginx

复制代码

用ps aux来查看nginx是否启动

  1. ps aux|grep nginx

复制代码

然后配置服务

  1. vim /usr/lib/systemd/system/nginx.service

复制代码

按i输入以下内容

  1. [Unit]
  2. Description=nginx - high performance web server
  3. Documentation=http://nginx.org/en/docs/
  4. After=network.target remote-fs.target nss-lookup.target
  5. [Service]
  6. Type=forking
  7. PIDFile=/var/run/nginx.pid
  8. ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
  9. ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
  10. ExecReload=/bin/kill -s HUP $MAINPID
  11. ExecStop=/bin/kill -s QUIT $MAINPID
  12. PrivateTmp=true
  13. [Install]
  14. WantedBy=multi-user.target

复制代码

编辑好后保存

然后开启开机启动

  1. systemctl enable nginx.service

复制代码

用命令关掉nginx

  1. pkill -9 nginx

复制代码

后面可以用systemctl来操作nginx.service

  1. systemctl start nginx.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值