Linux

您所在的位置:网站首页 linux打印服务器搭建 Linux

Linux

2023-06-20 19:46| 来源: 网络整理| 查看: 265

1.安装nginx软件–》web服务器–》搭建网站的软件

[root@localhost lianxi]# yum install epel-release -y 安装epel源软件--》这个网站有很多的软件可以下载 [root@localhost lianxi]# yum install nginx -y 安装nginx软件

2.将/lianxi目录下的index.html复制到/usr/share/nginx/html/

[root@localhost python-test]# cp index.html /usr/share/nginx/html/ cp:是否覆盖"/usr/share/nginx/html/index.html"? y

这个步骤是将 /lianxi 目录下的 index.html 文件复制到 /usr/share/nginx/html/ 目录中,以便 Nginx 可以将其用作默认网页。/usr/share/nginx/html/ 目录通常是 Nginx 服务器默认的文档根目录,因此将 index.html 文件复制到该目录中将允许您通过 Web 浏览器访问该文件。

当我们在浏览器中输入 Nginx 服务器的 IP 地址或域名时,Nginx 将默认查找 /usr/share/nginx/html/ 目录中的 index.html 文件并将其作为默认页面呈现。因此,如果我们想要在 Nginx 服务器上显示自己的网页内容,需要将我们的网页文件复制到该目录中。

3.启动nginx

[root@localhost python-test]# service nginx start Redirecting to /bin/systemctl start nginx.service

4.访问网站,在windows里打开浏览器去访问ip地址

[root@localhost python-test]# ip add 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:10:22:3d brd ff:ff:ff:ff:ff:ff inet 192.168.242.137/24 brd 192.168.242.255 scope global noprefixroute dynamic ens33 valid_lft 1153sec preferred_lft 1153sec inet6 fe80::8b4a:aca4:d50c:9b86/64 scope link noprefixroute valid_lft forever preferred_lft forever

最后页面出现想要的画面就算成功了,如下: 在这里插入图片描述

当网站访问不了的时候可以尝试下面的操作: 关闭防火墙

[root@localhost python-test]# service firewalld stop Redirecting to /bin/systemctl stop firewalld.service


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3