💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
第一种方法:通过配置EPEL源,然后通过yum安装Nginx服务 1、配置EPEL源,我这边以阿里云镜像为例(http://mirrors.aliyun.com/) [root@static ~]# cd /etc/yum.repos.d/ [root@static yum.repos.d]# ll total 24 -rw-r--r--. 1 root root 1991 Dec 1 16:16 CentOS-Base.repo -rw-r--r--. 1 root root 647 Dec 1 16:16 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 289 Dec 1 16:16 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Dec 1 16:16 CentOS-Media.repo -rw-r--r--. 1 root root 6259 Dec 1 16:16 CentOS-Vault.repo [root@static yum.repos.d]# wget -O /etc/yum.repos.d/epel-6.repo http://mirrors.aliyun.com/repo/epel-6.repo --2017-12-01 16:17:36-- http://mirrors.aliyun.com/repo/epel-6.repo Resolving mirrors.aliyun.com... 180.163.159.87, 180.163.159.88, 180.163.159.100, ... Connecting to mirrors.aliyun.com|180.163.159.87|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1083 (1.1K) [application/octet-stream] Saving to: “/etc/yum.repos.d/epel-6.repo” 100%[=====================================================================================================================================================>] 1,083 --.-K/s in 0s 2017-12-01 16:17:47 (150 MB/s) - “/etc/yum.repos.d/epel-6.repo” saved [1083/1083] (如果wget命令没有,请通过yum安装(yum -y install wget) [root@static yum.repos.d]# [root@static yum.repos.d]# ll epel-6.repo (查看刚刚下载的epel,目录里是否有) -rw-r--r--. 1 root root 1083 Jul 2 2014 epel-6.repo 2、查看nginx的版本 [root@static ~]# yum info nginx ![nginx查看](https://box.kancloud.cn/3b4c3762062397ea088b10e9b63e9060_822x427.png) 3、通过Yum安装nginx [root@static ~]# yum -y install nginx 4、通过yum安装nginx的目录结构 配置文件: /etc/nginx 启动脚本:/etc/rc.d/init.d/nginx 脚本配置文件:/etc/sysconfig/nginx nginx命令:/usr/sbin/nginx 模块文件:/usr/lib64/nginx/modules 说明文档目录:/usr/share/doc/ 日志切割:etc/logrotate.d/nginx 日志文件:/var/log/nginx 默认主目录:/usr/share/nginx/html/ 5、启动Nginx服务并测试 [root@static ~]# service nginx start Starting nginx: [ OK ] [root@static ~]# ss -tunlp|grep 80 tcp LISTEN 0 128 :::80 :::* users:(("nginx",1587,7),("nginx",1589,7)) tcp LISTEN 0 128 *:80 *:* users:(("nginx",1587,6),("nginx",1589,6)) 关闭防火墙,或者放行80端口的访问 [root@static ~]# service iptables stop [root@static ~]# iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT [root@static ~]# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] 关闭Selinux服务 [root@static ~]#setenforce 0 临时关闭 [root@static ~]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config [root@static ~]# cat /etc/selinux/config (重启服务器后生效) # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted 测试访问如下 ![nginx测试访问(yum01)](https://box.kancloud.cn/bc5d7e144d43bc80e6fe201a84ccf4e6_1310x467.png) 第二种: 通过nginx yum repository安装最新版本的nginx 1、配置yum源 [root@static ~]# vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1 注意: baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively. 2、查看nginx版本 [root@static ~]# yum info nginx ![nginxwending](https://box.kancloud.cn/c52e9cc5e7ebcdd50bbaf845830c20de_661x389.png) 3、安装nginx [root@static ~]# yum -y install nginx 4、Nginx的目录结构 配置文件: /etc/nginx 日志文件: /var/log/nginx 默认主目录: /usr/share/nginx/html 模块目录: /usr/lib64/nginx/modules 启动脚本:/etc/rc.d/init.d/nginx 说明文档目录: /usr/share/doc/ 5、启动nginx服务 [root@static nginx]# service nginx start Starting nginx: [ OK ] [root@static nginx]# ss -tunlp|grep nginx tcp LISTEN 0 128 *:80 *:* users:(("nginx",1476,6),("nginx",1478,6))