-
网站简介
网站的名词解释
HTML 是超文本标记语言
网页 使用计算机语言如Java html5 php等语言编辑的文本
主页 网页中呈现于低用户的第一个页面 一般默认为index.html
网站 多个网页组合而成的一个服务器
URL 统一资源定位符 用于网页的访问
网站的架构
常见的分为两种LAMP 和 LNMP
LAMP为: Linux Apache Mariadb PHP
LNMP为: Linux Nginx Mariadb PHP
此次我们主要采用的是LAMP架构 -
虚拟主机说明:
因为一台服务器上我们可能会部署多个网站 一台服务器部署多个网站有三种方法
第一种 域名解析 我们可以将我们的网站一一购买域名对其进行解析
第二种 使用不同的端口 如121.36.125.251:80 121.36.125.251:81等不同的端口
第三种 使用不同的IP 但其需要很多网卡进行IP的绑定
此次实验我们采取的方法为第一种 使用域名对其解析
Linux服务器环境要求:
将防火墙和selinux 关闭
systemctl stop firewalld # 关闭防火墙
systemctl disable firewalld #将防火墙设置为开机不自启
setenforce 0 #关闭selinux
yum -y install httpd # 安装httpd
systemctl start httpd # 启动httpd
httpd 配置文件说明:
/etc/http里面
conf为http的主配置文件
conf.d 为http的子配置文件(我们部署多个网站应在这里写如配置文件)
/var/www/html 文件里面为httpd的默认网页文件存放目录
mkdir /var/www/html/a.com #在html文件夹创建一个a.com的文件夹用于存
#放index.html
echo 网页测试 > /var/www/html/a.com/index.html #将测试内容“网页测试”
#写入index.html
vim /etc/httpd/conf.d/a.com.conf #在httpd的子配置文件中写入a.com的配置信息
#以下为vim内容
<VirtualHost *:80> # 固定格式 声明ip及端口
ServerName www.a.com # 声明域名地址
DocumentRoot /var/www/html/a.com #声明主页存放目录
</VirtualHost> # 固定格式
创建第二个网站b.com的配置文件
mkdir /b.com #创建一个存放b.com的主页存放路径
echo 网页测试B > /b.com/index.html #将测试内容信息写入主页
vim /etc/http/conf.d/b.com.conf #编辑b.com的配置文件信息
<VirtualHost *:80>
ServerName www.b.com
DocumentRoot /b.com
</VirtualHost>
<Directory "/b.com"> #说明赋予权限的目录
Require all granted #同意所有请求
</Directory>
所有程序修改完配置文件后需要重启服务才可以重新应用配置文件的信息
httpd -v #查看httpd的版本
httpd -t #检查httpd配置文件是否有误
[Thu Aug 20 21:14:08.558902 2020] [core:error] [pid 3321] (EAI 2)Name or service not known: AH00547: Could not resolve host name *\xef\xbc\x9a80 -- ignoring!
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK #表示没有问题
systemctl restart httpd # 重启httpd服务
因为此次域名我没没有购买需要我们对访问服务器的电脑进行自主shi域名解析
Linux域名解析配置文件为 /etc/hosts
windows 域名解析配置文件为 C:\Windows\System32\drivers\etc\hosts
书写格式为
192.168.88.134 www.a.com
IP地址 域名
修改完后保存
通过浏览器访问即可
3. 论坛网站的发布
论坛网站采用的是LAMP架构
yum -y install httpd mariadb-server mariadb gd php-mysql php-gd #安装相应
#的软件 mariadb为数据库
wget http://download.comsenz.com/DiscuzX/2.5/Discuz_X2.5_SC_UTF8.zip #下载部署包
yum -y install unzip #安装unzip的解压软件
unzip download.comsenz.com/DiscuzX/2.5/Discuz_X2.5_SC_UTF8.zip #解压
mkdir /discuz #创建存放目录
cp -r upload/ /discuz 将其复制至discuz
chown -R apache.apache /discuz/ #将下载文件的属主属组改成apache
vim /etc/http/conf.d/discuz.com.conf #编辑b.com的配置文件信息
<VirtualHost *:80>
ServerName www.discuz.com
DocumentRoot /discuz
</VirtualHost>
<Directory "/discuz"> #说明赋予权限的目录
Require all granted #同意所有请求
</Directory>
systemctl start httpd mariadb
mysql #进入数据库
show databases; #查看数据库
create database discuz; #创建discuz的数据库
quit
在windows文件中修改域名解析文件 访问域名 点击安装 按照是配置信息填写即可