本次实验实现目的:
安装Nginx,Nginx开启目录浏览、下载功能,开机默认启动;咐件自带开机启动脚本、重启脚本;
1、关闭SELINUX
查看获取SELinux的状态:
[root@localhost ~]# getenforce
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled #默认为:enforcing
2、添加开放nginx端口号
查看获取iptables的状态:
[root@localhost ~]# service iptables status
在防火墙IPtables 添加nginx监听的端口80;
[root@localhost ~]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
:wq #保存
重启IPtables
[root@localhost ~]# service iptables restart
确认安装成功并启动:nginx监听的端口80;
[root@localhost ~]# netstat -na |grep :80
3、下载软件包
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
[root@localhost src]# wget http://nginx.org/download/nginx-1.3.8.tar.gz
4、安装pcre 让安装Nginx支持rewrite 方便以后所需
方法1:
[root@localhost ~]# yum install pcre*
方法2:
[root@localhost src]# tar zxvf pcre-8.31.tar.gz
[root@localhost src]# cd pcre-8.31
[root@localhost pcre-8.31]# ./configure
[root@localhost pcre-8.31]# make;make install
5、安装nginx
将nginx-1.3.8.tar.gz传到/usr/local/src(安装需要编译的软件,最好放到这个目录下)。
[root@localhost src]# tar zxvf nginx-1.3.8.tar.gz
[root@localhost src]# cd nginx-1.3.8
[root@localhost nginx-1.3.8]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.3.8]# make;make install
6、安装Apache
[root@localhost ~]# yum install http*
[root@localhost ~]# service httpd restart