为什么 centos 7 安装 nginx 后显示 Welcome to nginx on Fedora
的有关信息介绍如下:安装环境为:最小化安装的centos7,关闭seliunx。最小化安装centos:关闭selinuxsed–i‘s/SELINUX=enforcing/SELINUX=disabled/g’/etc/selinux/config开始安装nginx1.7.8创建群组groupaddpilerccisnotfound解决方法:yuminstallgccgcc-c++如果有错误提示:./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.Youcaneitherdisablethemodulebyusing–without-http_rewrite_moduleoption,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrarystaticallyfromthesourcewithnginxbyusing–with-pcre=option.解决方法:yuminstallpcre-devel如果有错误提示:./configure:error:SSLmodulesrequiretheOpenSSLlibrary.Youcaneitherdonotenablethemodules,orinstalltheOpenSSLlibraryintothesystem,orbuildtheOpenSSLlibrarystaticallyfromthesourcewithnginxbyusing–with-openssl=option.解决方法:yuminstallopenssl-devel以上错误提示依次解决后:再一次的运行./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module--with-http_gzip_static_modulemakemekeinstall编译参数解释:#指定运行权限的用户--user=www#指定运行的权限用户组--group=www#指定安装路径--prefix=/usr/local/nginx#支持nginx状态查询--with-http_stub_status_module#开启ssl支持--with-http_ssl_module#开启GZIP功能--with-http_gzip_static_module因此要顺利的通过nginx编译安装必须安装的依赖关系有:yuminstallgcgccgcc-c++pcre-develzlib-developenssl-devel2、在centos7中为nginx的启动、重启、重载配置添加脚本nginx直接启动的方法:/usr/local/nginx/sbin/nginx但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。编辑文件:vim/usr/lib/systemd/system/nginx.service添加下面的脚本,注意路径![Unit]Description=nginx-highperformancewebserverDocumentation=kill-sQUIT$MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.targetsystemctl的一些使用方法:systemctlis-enabledservicename.service#查询服务是否开机启动systemctlenablexxx.service#开机运行服务systemctldisablexxx.service#取消开机运行systemctlstartxxx.service#启动服务systemctlstopxxx.service#停止服务systemctlrestartxxx.service#重启服务systemctlreloadxxx.service#重新加载服务配置文件systemctlstatusxxx.service#查询服务运行状态systemctl--failed#显示启动失败的服务因此,添加上面脚本后,centos7中操作nginx的方法有systemctlis-enablednginx.service#查询nginx是否开机启动systemctlenablenginx.service#开机运行nginxsystemctldisablenginx.service#取消开机运行nginxsystemctlstartnginx.service#启动nginxsystemctlstopnginx.service#停止nginxsystemctlrestartnginx.service#重启nginxsystemctlreloadnginx.service#重新加载nginx配置文件systemctlstatusnginx.service#查询nginx运行状态systemctl--failed#显示启动失败的服务