CentOS 安装 nginx 教程

CentOS 安装 nginx 教程

下载安装包

cd /usr/local
wget http://nginx.org/download/nginx-1.19.8.tar.gz

安装依赖

yum install gcc-c++
yum install pcre
yum install pcre-devel
yum install zlib 
yum install zlib-devel
yum install openssl
yum install openssl-devel

解压缩安装包

tar -zxvf nginx-1.19.8.tar.gz
cd /usr/local/nginx-1.19.8/

编译执行

./configure --with-http_ssl_module
make
make install

删除解压包

cd ..
rm -fr nginx-1.19.8

建立快捷方式

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx -f

安装服务

cd /usr/lib/systemd/system/
vi nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://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. 激活服务
systemctl enable nginx
  1. 启动服务
systemctl start nginx
posted @ 2021-06-12 19:29  ArgoZhang  阅读(134)  评论(0编辑  收藏  举报