微信小程序视频网站开发教程,江安网站建设,西安高风险调整,有了ddns怎么建设网站文章目录 Nginx源码安装注安装pcre库安装openssl库创建用户及用户组安装编译环境解压文件检测环境重要目录检查配置服务启动脚本查看效果#xff1a; Nginx源码安装
注
本实验基于RHEL73.10.0-327.el7.x86_64#xff0c;尽量使用RHEL7或CentOS7。
安装pcre库
安装 pere 库… 文章目录 Nginx源码安装注安装pcre库安装openssl库创建用户及用户组安装编译环境解压文件检测环境重要目录检查配置服务启动脚本查看效果 Nginx源码安装
注
本实验基于RHEL73.10.0-327.el7.x86_64尽量使用RHEL7或CentOS7。
安装pcre库
安装 pere 库是为了使 Nginx 支持具备 URI 重写功能的 rewrite 模块如果不安装 pere 库则Nginx无法使用该模块。
yum install -y pcre-devel安装openssl库
防止安装过程中报错。
yum install -y openssl-devel创建用户及用户组
groupadd -g 958 nginx
useradd -u 956 -g 958 -c Nginx User -s /sbin/nologin nginx安装编译环境
yum install gcc gcc-c make解压文件
tar zxvf nginx-1.22.0.tar.gz -C /usr/local/src/
drwxr-xr-x. 8 1001 1001 4096 May 24 2022 nginx-1.22.0检测环境
执行nginx目录下的configure脚本
./configure
#检查汇总
Configuration summary using system PCRE library OpenSSL library is not used using system zlib librarynginx path prefix: /usr/local/nginxnginx binary file: /usr/local/nginx/sbin/nginxnginx modules path: /usr/local/nginx/modulesnginx configuration prefix: /usr/local/nginx/confnginx configuration file: /usr/local/nginx/conf/nginx.confnginx pid file: /usr/local/nginx/logs/nginx.pidnginx error log file: /usr/local/nginx/logs/error.lognginx http access log file: /usr/local/nginx/logs/access.lognginx http client request body temporary files: client_body_tempnginx http proxy temporary files: proxy_tempnginx http fastcgi temporary files: fastcgi_tempnginx http uwsgi temporary files: uwsgi_tempnginx http scgi temporary files: scgi_temp
#然后
make
#再
make install重要目录
[rootnginx nginx]# tree -d -L 1
.
├── client_body_temp
├── conf #配置文件存放
├── fastcgi_temp
├── html #工作目录等价于apache /var/www/html
├── logs #日志文件及pid文件
├── proxy_temp
├── sbin #启动脚本存放目录
├── scgi_temp
└── uwsgi_temp检查
#查看Nginx版本
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
configure arguments:
#启动Nginx
/usr/local/nginx/sbin/nginx
#查看监听端口
netstat -lnutp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 33728/nginx: master配置服务启动脚本
vim /usr/lib/systemd/system/nginx.service
#Contents
[Unit]
Descriptionnginx - high performance web server
Documentationhttp://nginx.org/en/docs/
Afternetwork.target remote-fs.target nss-lookup.target[Service]
Typeforking
PIDFile/usr/local/nginx/logs/nginx.pid #这里的pidFile一定要和配置汇总里的对应。
ExecStart/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload/bin/sh -c /bin/kill -s HUP $(/bin/cat /usr/local/nginx/logs/nginx.pid)
ExecStop/bin/sh -c /bin/kill -s TERM $(/bin/cat /usr/local/nginx/logs/nginx.pid)[Install]
WantedBymulti-user.target
#检查
systemctl daemon-reload
#在使用systemctl启动前记得杀死nginx的进程不然重启会失败。详细可以看错误日志。
systemctl restart nginx.service
netstat -lnutp| grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 70435/nginx: master 至此Nginx源码安装完成。
查看效果
#因为我这边虚拟机没有安装界面所以只能在物理机上访问所以防护墙必须关。
systemctl stop firewalld.servicesed -i s/^SELINUXenforcing/SELINUXPermissive/ /etc/selinux/config