1.第一种是用yum源安装nginx(yum源中没有Tengine)
没有yum源的可以执行以下命令下载阿里云的yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
(这个源是Centos自带的,含有绝大多数的软件)、
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
(这个是第三方软件仓库,几乎绝大多数的软件都能下载,如果没有的软件就需要自行去寻找下载的连接了)
之后就执行
yum install nginx -y
这会自动给你下载安装到系统默认的目录中,这时候就可以用systemctl管理工具去管理nginx了
systemctl start nginx(开启nginx)
systemctl stop nginx(关闭nginx)
systemctl restart nginx(重启nginx)
(最重要的一部分)
iptables -F(重置防火墙规则)
systemctl stop firewalld(关闭防火墙)
用命令查询一下端口是否在运行
ps -ef|grep nginx
查询一下nginx的进程信息
之后访问本地的ip地址例如 192.168.***.*** 默认是80端口(两个页面其中一个出现都是正确的)
2.自定义安装Tengine的安装目录
先下载Tengine(淘宝nginx)的压缩包,wget(wget -O 需要加指定目录)没有加参数下载到当前目录
wget https://tengine.taobao.org/download/tengine-3.1.0.tar.gz
查询一下
[root@chunguang opt]# cd tengine-3.1.0/
[root@chunguang tengine-3.1.0]# ll
总用量 420
[root@chunguang tengine-3.1.0]# ls
AUTHORS.te CHANGES CHANGES.te configure docs LICENSE modules README.markdown tests
auto CHANGES.cn conf contrib html man packages src THANKS.te
.需要Linux系统文件支持https的模块,就是安装openssl模块
yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel
执行编译参数,让nginx的安装,可以扩展其他功能
这里解释一下哈需要再Tengine的安装目录中找到configure文件(./configure --prefix=/opt/my_tengine/)这里它会自动在/opt文件下创建一个my_tengine文件(指定的安装路径)
./configure --prefix=/opt/my_nginx/ --with-http_ssl_module --with-http_stub_status_module
make && make install
然后运行Tengine(找到nginx的可执行文件)
/opt/my_nginx//sbin/nginx
然后查看一下Tengine的网络进程信息
ps -ef |grep nginx
netstat -tunlp|grep nginx
这个时候也要关闭防火墙
systemctl stop firewalld