搭建属于自己本地的网站

1.关闭selinux
1.1 为什么关闭?

如果selinux不关闭的话,修改ssh端口等策略会不生效,

比如向将ssh端口修改为22011,修改后重启sshd服务,端口未修改,此时需要执行setendforce 0 命令,然后再次重启sshd服务就可以了

1.2如何关闭

1.2.1、临时关闭:输入命令setenforce 0,重启系统后还会开启。
1.2.2、永久关闭:输入命令vi /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,然后保存退出

2.关闭防火墙

systemctl stop firewalld (1:暂时关闭防火墙)

systemctl disable firewalld (2:永久关闭防火墙)

systemctl status firewalld (3:查看防火状态)

3.下载NGINX

yum install nginx -y

4.设置
systemctl start nginx # 启动httpd
systemctl enable nginx # 设置开机启动
5.配置IP地址与域名的映射关系
vim /etc/hosts
6. 配置主配置文件

vim /etc/nginx/nginx.conf

 server {
        listen 80;
        server_name www.haha.com; # 重点,需要写域名
        root /www/haha;
        error_page 404 /404.html;
                location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
                location = /50x.html {
                }
        }
7重启服务,测试

systemctl restart nginx

8.本地输入域名查看

curl www.haha.com

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值