下载
http://nginx.org/en/download.html
安装
安装依赖
yum -y install gcc gcc-c++ zlib zlib-devel pcre-devel openssl openssl-devel
把安装文件上传到服务器(也可以wget获取,wget http://nginx.org/download/nginx-1.15.12.tar.gz)
解压
tar -zxvf nginx-1.15.12.tar.gz
添加nginx用户,默认会添加一个同名的用户组(也可以不添加)
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
make && make install
添加软连接
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
回到家目录,执行nginx
netstat -lntp | grep nginx
访问
也可以这样访问,curl 192.168.116.128:80
如果没有添加软链接,就要这样启动(重启是:./nginx -s reload)
改了配置文件,重启服务:nginx -s reload
上面显示的内容的位置:
root文件夹下的html文件夹中的文件
访问的就是index.html
参考:http://www.runoob.com/linux/nginx-install-setup.html