首先,需要安装一些编译 Nginx 所需的依赖包,使用以下命令:
yum -y install gcc pcre - devel zlib - devel openssl - devel
下载
https://nginx.org/en/download.html
上传到opt目录下
或者直接在linux系统里下载
wget http://nginx.org/download/nginx-1.26.2.tar.gz
如果command not found,要先安装wget下载命令器,
yum install wget -y
解压
cd opt
tar -zxvf nginx-1.26.2.tar.gz
cd nginx-1.26.2
./configure #配置编译选项
make && make install #编译安装
/usr/local/nginx/sbin/nginx #启动
ps -ef | grep nginx #查看
通过ip地址(服务器ip)+端口号(默认80)
记得要开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
配置
find / -name "nginx.conf"
#/usr/local/nginx/nginx-1.26.2/conf/nginx.conf
#/usr/local/nginx/conf/nginx.conf
#/opt/nginx-1.26.2/conf/nginx.conf
找到Nginx配置文件在哪
ps -ef | grep nginx
# 取主进程id
ll /proc/#主进程id
#这里是ll /proc/9959
#取exe后的路径
exe -> /usr/local/nginx/sbin/nginx
#/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
配置
找到Nginx配置文件在哪
ps -ef | grep nginx
# 取主进程id
ll /proc/#主进程id
#这里是ll /proc/9959
#取exe后的路径
exe -> /usr/local/nginx/sbin/nginx
#/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
编辑配置
cat /usr/local/nginx/conf/nginx.conf
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx-default.conf
vi /usr/local/nginx/conf/nginx.conf
最后检查
#检查语言错误
/usr/local/nginx/sbin/nginx -t
#没问题的话,重新加载配置文件
/usr/local/nginx/sbin/nginx -s reload
标签:sbin,nginx,安装,CentOS7,Nginx,usr,conf,local
From: https://www.cnblogs.com/ritchieojo/p/18492466