一、nginx服务测试
1.安装Nginx软件所需依赖包
yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake wget httpd-tools
2.配置nginx官方 yum源
[root@web ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
3.检查官方源是否配置成功
yum list nginx
4.安装nginx服务
yum install -y nginx
5.查看nginx是否安装成功
[root@buyaolang ~]# rpm -qa nginx
nginx-1.16.0-1.el7.ngx.x86_64
6.创建站点目录
[root@buyaolang conf.d]# mkdir /var/html/www -p
7.编写一个nginx网站配置文件
[root@buyaolang conf.d]# vim 01.www.conf
server{
listen 80;
server_name www.bossx.com
location / {
root /var/html/www
index index.html
}
}
8.在站点目录下编写一个首页文件
[root@buyaolang www]# vim index.html
www.bossx.com
9.检查nginx语法是否正确
[root@buyaolang www]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
9.修改站点目录属主属组
[root@buyaolang www]# chown nginx.nginx /var/html/www/ -R
-R 递归修改属主属组
10.启动服务并且加入开机自启
[root@buyaolang www]# systemctl start nginx
[root@buyaolang www]# systemctl enable nginx
11.检查服务是否启动
[root@buyaolang www]# ps -ef |grep nginx
root 10065 1 0 03:36 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 10066 10065 0 03:36 ? 00:00:00 nginx: worker process
12.查看nginx服务端口
[root@buyaolang www]# ss -lntup |grep nginx
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=10066,fd=6),("nginx",pid=10065,fd=6))
13.在阿里云安全组中开启80端口
14.浏览器测试