在 centos 7 中编译安装 nginx
2017-01-09 14:53
666 查看
摘要: 亲测可行,参考https://www.cnhzz.com/centos_nginx(非常感谢),略有修改
如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
如果有错误提示:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-https_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解决方法:
如果有错误提示:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
以上错误提示依次解决后:再一次的运行
编译参数解释:
因此要顺利的通过nginx编译安装必须安装的依赖关系有:
3ff0
法:
但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
systemctl的一些使用方法:
因此,添加上面脚本后,centos7 中操作nginx的方法有
安装环境为:最小化安装的centos7。
开始安装nginx1 2 3 4 5 6 7 8 9 10 11 | 创建群组 groupadd www 创建一个用户,不允许登陆和不创主目录 useradd -s /sbin/nologin -g www -M www #下载最新版nginx wget -C https://nginx.org/download/nginx-1.7.8.tar.gz tar zxvf nginx-1.7.8.tar.gz #编译基本能运行的nginx ./configure --user=www --group=www --prefix=/usr/local/nginx --with-https_stub_status_module --with-https_ssl_module --with-https_gzip_static_module make make install |
./configure: error: C compiler cc is not found
解决方法:
1 | yum install gcc gcc-c++ |
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-https_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解决方法:
1 | yum install pcre-devel |
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
1 | yum install openssl-devel |
1 2 3 | ./configure --user=www --group=www --prefix=/usr/local/nginx --with-https_stub_status_module --with-https_ssl_module --with-https_gzip_static_module make make install |
1 2 3 4 5 6 7 8 9 10 11 12 | #指定运行权限的用户 --user=www #指定运行的权限用户组 --group=www #指定安装路径 --prefix=/usr/local/nginx #支持nginx状态查询 --with-https_stub_status_module #开启ssl支持 --with-https_ssl_module #开启GZIP功能 --with-https_gzip_static_module |
1 | yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel |
2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方3ff0
法:
1 | /usr/local/nginx/sbin/nginx |
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [Unit] Description=nginx - high performance web server Documentation=https://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 | systemctl is-enabled servicename.service #查询服务是否开机启动 systemctl enable xxx.service #开机运行服务 systemctl disable xxx.service #取消开机运行 systemctl start xxx.service #启动服务 systemctl stop xxx.service #停止服务 systemctl restart xxx.service #重启服务 systemctl reload xxx.service #重新加载服务配置文件 systemctl status xxx.service #查询服务运行状态 systemctl --failed #显示启动失败的服务 |
1 2 3 4 5 6 7 8 9 | systemctl is-enabled nginx.service #查询nginx是否开机启动 systemctl enable nginx.service #开机运行nginx systemctl disable nginx.service #取消开机运行nginx systemctl start nginx.service #启动nginx systemctl stop nginx.service #停止nginx systemctl restart nginx.service #重启nginx systemctl reload nginx.service #重新加载nginx配置文件 systemctl status nginx.service #查询nginx运行状态 systemctl --failed #显示启动失败的服务 |
copyright = { "作者": "墨衣夜行", "本文链接": "http://my.oschina.net/letao/blog/524487" }
相关文章推荐
- CentOS 5.6(X64)下编译安装LNMP平台(Nginx1.0+PHP5.3.6+Mysql5.5.11)
- CentOS 编译 nginx+php+mysql 安装手记
- CentOS 编译安装Nginx1.0.12+MySQL5.5.21+PHP5.3.10
- centos 编译安装 nginx
- CentOS 6.3 编译安装 配置 nginx server php mysql c gcc g++ c++等
- CentOS 编译 nginx+php+mysql 安装手记
- CentOS源码编译安装Nginx和tcp_proxy module
- CentOS 5.x,6.0编译安装Nginx1.2.3+MySQL5.5.15+PHP5.3.6
- CentOS 6.2 上编译安装 Nginx 1.0.15 + PHP 5.3.12 + MySQL 5.1.62
- CentOS6.3源码编译安装nginx
- CentOS 5.6(X64)下编译安装LNMP平台(Nginx1.0.4+PHP5.3.6+Mysql5.5.12)
- CentOS 6 编译安装Nginx+PHP+Mysql
- 编译安装LNMP Centos 6.5 x64 + Nginx1.6.0 + PHP5.5.13 + Mysql5.6.19
- CentOS5.6(64bit)下编译安装Nginx1.2.0、Percona-Server-5.1.61、PHP5.3.10
- 编译安装nginx with uwsgi module on centos
- 64位centos上nginx,php编译安装遇configure: error: Cannot find libmysqlclient under /usr 错误解决
- Centos-Server-Nginx服务(编译安装)
- CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 + Mysql5.5.18 )
- centos下编译安装nginx,并增加nginx_upstream_check_module模块
- centos 下 编译安装 nginx + mysql + php 服务