安装nginx
-
下载
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
-
解压
tar -zvxf nginx-1.10.1.tar.gz
-
重命名
mv nginx-1.10.1 song-nginx
-
安装依赖库
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
-
进入song-nginx目录
./configure make make install # 此时退出到上一级目录,可以发现有一个新的nginx目录
-
配置nginx开启启动
cd /lib/systemd/system vim nginx.service # 添加一下内容 [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx reload ExecStop=/usr/local/nginx/sbin/nginx quit PrivateTmp=true [Install] WantedBy=multi-user.target # 设置开机自启 systemctl enable nginx.service
-
启动nginx
systemctl start nginx.service
-
关闭nginx服务
systemctl stop nginx.service
-
如何验证nginx安装成功
在浏览器输入自己的主机ip即可,出现 Welcome to nginx!即是成功