最近搭建centos6.8的项目运行环境,记录nginx的安装步骤:
-
安装nginx需要的依赖
[root@VM_0_17_centos centos]# yum install gcc-c++
[root@VM_0_17_centos centos]# yum install pcre pcre-devel
[root@VM_0_17_centos centos]# yum install zlib zlib-devel
[root@VM_0_17_centos centos]# yum install openssl openssl-devel
-
下载nginx,并解压
稳定版本Stable version:http://nginx.org/en/download.html
上传linux目录下
[root@VM_0_17_centos centos]# tar -zxvf nginx-1.14.0.tar.gz
[root@VM_0_17_centos centos]# cd nginx-1.14.0
执行检查:
[root@VM_0_17_centos nginx-1.14.0]# ./configure
[root@VM_0_17_centos nginx-1.14.0]# make
[root@VM_0_17_centos nginx-1.14.0]# make install
查看nginx安装路径
[root@VM_0_17_centos nginx-1.14.0]# whereis nginx
启动nginx
[root@VM_0_17_centos nginx-1.14.0]# cd /usr/local/nginx/sbin/
[root@VM_0_17_centos sbin]# ./nginx
查看是否启动成功
[root@VM_0_17_centos sbin]# ps aux | grep nginx
root 21893 0.0 0.0 18068 644 ? Ss 13:08 0:00 nginx: master process ./nginx
nobody 21894 0.0 0.0 18512 1252 ? S 13:08 0:00 nginx: worker process
root 21921 0.0 0.0 103440 920 pts/1 S+ 13:09 0:00 grep nginx看到
nginx: master process ./nginx
表示启动成功 -
nginx默认使用80端口,所以只需要
http://ip
访问就可以了
显示以下就成功了Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.注:如果是本地访问服务器,需要在防火墙开放80端口
[root@VM_0_17_centos sbin]# vim /etc/sysconfig/iptables
加入
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
重启服务即可
[root@VM_0_17_centos sbin]# service iptables restart