阿里云服务器搭建---nginx服务

一、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端口
开启80端口01
开启80端口02
开启80端口03
14.浏览器测试
测试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值