CentOS7设置nginx开机自启动方式_第1页
CentOS7设置nginx开机自启动方式_第2页
CentOS7设置nginx开机自启动方式_第3页
CentOS7设置nginx开机自启动方式_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、CentOS7设置nginx开机自启动手动安装nginx参考 HYPERLINK /hafiz/p/6891458.html?utm_source=itdadao&utm_medium=referral t _blank Centos7安装Nginx实战,安装步骤如下:1、安装gcc等编译环境yum -y install make zlib zlib-devel gcc-c+ libtool openssl openssl-devel2、下载nginx1.12.0并解压wget /download/nginx-1.12.0.tar.gztar -xzvf nginx-1.12.0.tar.gz

2、cd nginx-1.12.03、创建目录mkdir -p /var/tempmkdir -p /var/temp/nginxmkdir -p /var/temp/run/nginxchmod a+wrx -R temp4、配置编译选项./configure -prefix=/usr/local/nginx -pid-path=/var/temp/run/nginx/nginx.pid -lock-path=/var/lock/nginx.lock -error-log-path=/var/log/nginx/error.log -http-log-path=/var/log/nginx/ac

3、cess.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切记,pid-path不能设置为/var/run/nginx/ng

4、inx.pid。因为CentOS每次重启后,都会删除/var/run目录中的自建目录和文件,从而导致nginx自启动失败。5、编译安装make & make install进入/usr/local/nginx查看文件是否存在conf、sbin、html文件夹,若存在则安装成功6、测试启动/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf如果不指定-c,nginx在启动时默认加载conf/nginx.conf文件。7、测试访问curl localhost浏览器如果不能访问,就打开防火墙或者开端口。关闭防火墙,system

5、ctl stop firewalld.service开放端口,firewall-cmd -zone=public -add-port=80/tcp -permanent,firewall-cmd -reload设置开机启动步骤如下:1、在系统服务目录里创建nginx.service文件vi /usr/lib/systemd/system/nginx.service2、写入内容如下:UnitDescription=nginxAfter=network.target ServiceType=forkingExecStart=/usr/local/nginx/sbin/nginxExecReload

6、=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s quitPrivateTmp=true InstallWantedBy=multi-user.targetUnit:服务的说明Description:描述服务After:描述服务类别Service服务运行参数的设置Type=forking是后台运行的形式ExecStart为服务的具体运行命令ExecReload为重启命令ExecStop为停止命令PrivateTmp=True表示给服务分配独立的临时空间注意:Service的启动、重启、停止命令全部要求使用绝对路径Install运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为33、设置开机自启动systemctl enable nginx.service4、查看nginx状态systemctl status nginx.service很奇怪,明明启动成功了,为什么显示Active: inactive (dead)?5、杀死nginx重启nginxpkill -9 nginxps aux | grep nginxsystemctl start ngi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论