centos7如何自主正确地安装配置Nginx?
Admin 2023-07-04 群英技术资讯 871 次浏览
今天就跟大家聊聊有关“centos7如何自主正确地安装配置Nginx?”的内容,可能很多人都不太了解,为了让大家认识和更进一步的了解,小编给大家总结了以下内容,希望这篇“centos7如何自主正确地安装配置Nginx?”文章能对大家有帮助。yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel pcre pcre-devel
(PCRE 作用是让 Nginx 支持 Rewrite 功能)
1、下载Nginx
下载地址:http://nginx.org/,选择稳定版本(例如:nginx-1.12.0.tar.gz)
2、将下载的二进制包移动到/usr/local目录,解压缩文件包
tar zxvf nginx-1.12.0.tar.gz
3、进入安装目录,编译安装
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre --with-http_ssl_module
make
make install
安装完成后的摘要信息:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
默认安装到/usr/local/nginx目录。
4、查看Nginx版本
/usr/local/nginx/sbin/nginx -v
输出结果如下:
nginx version: nginx/1.12.0
到此,nginx安装完成。
5、启动、关闭Nginx
#检查配置文件是否正确
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -V # 可以看到编译选项
#启动Nginx
/usr/local/nginx/sbin/nginx # 默认配置文件 /usr/local/nginx/conf/nginx.conf,-c 指定
# 重新载入配置文件
/usr/local/nginx/sbin/nginx -s reload
#重启Nginx,不会改变启动时指定的配置文件
/usr/local/nginx/sbin/nginx -s reopen
#停止Nginx
/usr/local/nginx/sbin/nginx -s stop
或
pkill nginx
1、创建Nginx运行使用的用户www
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
2、配置nginx.conf,将/usr/local/nginx/conf/nginx.conf替换为以下内容
[plain] view plain copy
四、防火墙配置
CentOS7默认的防火墙为firewall
添加防火墙规则如下:
#firewall-cmd --add-port=80/tcp //http协议基于TCP传输协议,放行80端口
现在大家对于centos7如何自主正确地安装配置Nginx?的内容应该都有一定的认识了吧,希望这篇能对大家有所帮助。最后,想要了解更多,欢迎关注群英网络,群英网络将为大家推送更多相关的文章。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
linux中查看docker是否启动成功的方法:1、利用“systemctl list-units”命令,该命令可以查看当前已经启动的服务;2、利用systemctl命令,该命令用于进行服务管理,当参数设置为“status”时就可以查看当前服务的状态,语法为“systemctl status docker”。
CentOS7 搭建LVS+keepalived负载均衡
linux系统之虚拟内存的相关内容,不知道朋友们了解多少,对这方面需要深入探索的朋友,可以看看小编所整理的资料,或多或少能在工作中帮助到你 。
shell脚本基本命令:1、Shell的echo指令与PHP的echo指令类似,都是用于字符串的输出;2、printf命令模仿C程序库里的【printf()】程序;3、test命令用于检查某个条件是否成立。
Linux不能执行configure是因为缺少依赖的库,可以重新安装新的库来解决。解决方法:1、利用“yum install -y PCRE”语句安装pcre库,pcre是一个轻量级的perl函数库;2、利用“yum install -y pcre-devel”语句安装“pcre-devel”库即可。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008