一、以包的形式安装安装说明系统环境:centos-6.5
软件:nginx-1.6.2.tar.gz
安装方式:源码编译安装
安装位置:/opt/program/nginx-1.6.2
下载地址:http://nginx.org/en/download.html
安装前提在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:
# yum install gcc-c++
# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
# find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
检查系统安装的nginx:
卸载原有的nginx
# yum remove nginx
安装将安装包文件上传到/opt/software中执行以下操作:
# cd /opt/program
# mkdir nginx
# tar -zxvf ../software/nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# ./configure --prefix=/opt/program/nginx 注:处此是指定nginx的安装目录,大多用户习惯于安装在/usr/local/nginx下面
# make 编译
# make install 安装
配置 : 这步我没有执行,外部也可以访问
#修改防火墙配置:
# vi + /etc/sysconfig/iptables
#添加配置项
-a input -m state --state new -m tcp -p tcp --dport 80 -j accept
#重启防火墙
# service iptables restart
启动#方法1
# /opt/program/nginx/sbin/nginx -c /opt/program/nginx/sbin/nginx/conf/nginx.conf
#方法2
# /opt/program/nginx/sbin/nginx
停止#查询nginx主进程号
ps -ef | grep nginx
#停止进程
kill -quit 主进程号
#快速停止
kill -term 主进程号
#强制停止
pkill -9 nginx
重启# /opt/program/nginx/sbin/nginx -s reload
测试#测试端口
netstat –na|grep 80
#浏览器中测试
http://ip:80
二、以yum的方式安装
一、直接通过yum安装
# yum list | grep nginx
# yum -y install nginx
二、下载rpm包安装 php,nginx
# rpm -ivh http://nginx.org/packages/centos/6/noarch/rpms/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# yum -y install nginx
# yum -y php-fpm
# service php-fpm restart
# service nginx restart
# chkconfig php-fpm on 设置开机自动启动
# chkconfig nginx on 设置开机自动启动
# netstat -lntp | grep nginx 查看端口
参考网址:
http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html
以上就介绍了阿里云上centos6.5系统安装nginx,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。