一、系统环境:
Centos7.6系统最小化安装
二、最小化安装Linux之后需要安装开发者工具
yum -y groupinstall "Development Tools"
如果记不住工具包的名称,可以使用下面命令搜索
[root@localhost ~]# yum grouplist | more
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.bfsu.edu.cn
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
三、准备安装
1.1、下载rpm包
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
1.2、安装nginx的源码包
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
1.3、开始安装nginx
yum -y install nginx
1.4、启动nginx
systemctl start nginx
systemctl enable nginx
1.5、开启防火墙允许访问并关闭selinux
1.5.1、防火墙放行nginx服务或者80端口
firewall-cmd --add-service=http --permanent //或者
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
1.5.2、关闭selinux
setenforce 0 ###临时关闭
永久关闭可以修改/etc/selinux/config,修改SELINUX=permissive或disabled
或者使用:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
1.6、开启虚拟目录
1.6.1、编辑nginx的主配置文件default.cog
vi /etc/nginx/conf.d/default.conf
插入内容:
location /1 {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
###访问http://localhost/1,即可访问到/usr/share/nginx/html/1/index.html文件
1.7、测试
访问:http://localhost/1