检查环境
[root@freedom yum]# getenforce
Disabled
[root@freedom yum]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 四 2019-07-25 17:57:20 CST; 23min ago
安装lrzsz
lrzsz:Linux上传下载文件工具
[root@freedom yum]# yum install lrzsz -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 lrzsz-0.12.20-36.el7.x86_64 已安装并且是最新版本
无须任何处理
上传源码包
[root@freedom ~]# rz -E
rz waiting to receive.
解压缩源码包
[root@freedom ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg nginx-1.15.1.tar.gz 公共 模板 视频 图片 文档 下载 音乐 桌面
[root@freedom ~]# tar zxf nginx-1.15.1.tar.gz
[root@freedom ~]# cd nginx-1.15.1/
[root@freedom nginx-1.15.1]# ./configure
进行配置并解决依赖关系
./configure: error: C compiler cc is not found
[root@freedom nginx-1.15.1]# yum list |grep cc
[root@freedom nginx-1.15.1]# yum install gcc-* -y
[root@freedom nginx-1.15.1]# ./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
[root@freedom nginx-1.15.1]# rpm -qa pcre
pcre-8.32-17.el7.x86_64
[root@freedom nginx-1.15.1]# yum install pcre-* -y
[root@freedom nginx-1.15.1]# ./configure
./configure: error: the HTTP gzip module requires the zlib library.
[root@freedom nginx-1.15.1]# rpm -qa zlib
zlib-1.2.7-18.el7.x86_64
[root@freedom nginx-1.15.1]# yum install zlib-* -y
[root@freedom nginx-1.15.1]# ./configure
编译
[root@freedom nginx-1.15.1]# make
安装
[root@freedom nginx-1.15.1]# make install
启动服务
[root@freedom nginx-1.15.1]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
查看端口
[root@freedom nginx-1.15.1]# netstat -anp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 77837/nginx: master
unix 3 [ ] STREAM CONNECTED 133307 77837/nginx: master
unix 3 [ ] STREAM CONNECTED 133306 77837/nginx: master
添加防火墙
[root@freedom nginx-1.15.1]# firewall-cmd --add-port=80/tcp
success
[root@freedom nginx-1.15.1]# firewall-cmd --add-port=80/tcp --permanent
success