CentOS安装配置Nginx详细教程
CentOS安装配置Nginx详细教程
一、预先安装额外的依赖
yum -y install gcc gcc-c++
yum -y install pcre-devel
yum -y install openssl openssl-devel
二、下载nginx压缩包
下载地址:https://nginx.org/en/download.html
这里以在CentOS7_64位上安装nginx-1.24.0为例,下载如图压缩包:
三、上传压缩包
创建nginx文件夹,并上传压缩包至/usr/local/nginx
cd /usr/local/
mkdir nginx
四、解压nginx压缩包
cd nginx
tar -zxvf nginx-1.24.0.tar.gz
五、编译安装nginx
cd nginx-1.24.0
./configure
make && make install
六、运行nginx
# 启动Nginx服务
/usr/local/nginx/sbin/nginx
# 停止Nginx服务
/usr/local/nginx/sbin/nginx -s stop
# 如果修改了配置⽂件后想重新加载Nginx,可执⾏:
/usr/local/nginx/sbin/nginx -s reload
注意:nginx配置文件路径为/usr/local/nginx/conf/nginx.conf