Nginx介绍
Nginx是一款轻量级的 Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,由俄罗斯的程序设计师Igor Sysoev所开发,其特点是占有内存少,并发能力强。事实上nginx的并发能力确实在同类型的网页服务器中表现较好。
安装 Nginx
1.2Nginx基本使用
获取Nginx
Nginx的官方主页: http://nginx.org
关闭防火墙关闭selinux
[root@youngfit ~]# systemctl stop firewalld #关闭防火墙
[root@youngfit ~]# systemctl disable firewalld #开机关闭防火墙
[root@youngfit ~]# setenforce 0 #临时关闭selinux
[root@youngfit ~]# getenforce #查看selinux状态
Nginx安装:
Yum方式:
[root@youngfit ~]# cd /etc/yum.repos.d/
[root@youngfit yum.repos.d]# vi nginx.repo #编写nginx的yum源
[nginx]
name=nginx
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@youngfit yum.repos.d]# yum clean all
[root@youngfit yum.repos.d]# yum makecache
[root@youngfit ~]# yum install -y nginx #安装nginx
如何使nginx默认访问的页面显示的是图片
①将图片上传到 /usr/share/nginx/html/目录下
②vim /etc/nginx/conf.d/default.conf #修改配置文件
③systemctl reload nginx #重新加载一下nginx服务
④用浏览器访问虚拟主机的IP地址即可。