搭建属于自己本地的网站

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

搭建属于自己本地的网站_第1张图片

你可能感兴趣的:(服务器,linux,网络)