网站架构 LAMP Linux+Apache+MySQL+PHP
系统+服务器程序+数据管理软件+中间软件
静态网站:Apache:服务端口:80/tcp(http)443/tcp(https)
1.主配置文件 /etc/httpd/conf/httpd.conf
子配置文件:/etc/httpd/conf.d/*.conf
主目录:/var/www/html 网站源码位置
2. 虚拟主机
作用:在一台物理服务器上运行多个网站
类型:基于主机名 www.a.org www.b.org
a.配置虚拟主机目标:在一台服务器上,实现两个网站的架设
网站域名 网站资源存放目录
www.a.org /var/www/html/a.org
www.b.org /b.org
b.准备网站源码(网页)目录 mkdir /var/www/html/a.org
vim /var/www/html/a.org/index.html 输入网页内容 a.com.com.com
c.创建a.org的网站配置文件 vim /etc/httpd/conf.d/a.org.conf
某个虚拟主机 ServerName www.a.org 服务器起个名字 documentRoot /var/www/html/a.org d.检测配置文件语法,重启服务
httpd -t systemctl restart httpd
www.b.org站点设置
准备网站源码(网页)目录 mkdir /b.orgvim /b.rog/index.html 网页内容
创建a.org的网站配置文件 vim /etc/httpd/conf.d/b.org.conf
ServerName www.b.org documentRoot /b.org Require all granted 检测配置文件语法,重启服务
httpd -t systemctl restart httpd
去客户端测试
1.在Windows中做域名解析C:WindowsSystem32driversetchosts中添加上一行
192.168.31.134 www.a.org 192.168.31.134 www.b.org此时能够ping www.a.org www.b.org 能ping通
在网页中打开也会显示i内容
2.在Linux中测试
vim /etc/hosts 中添加
192.168.31.134 www.a.org 192.168.31.134 www.b.org字符浏览器测试 yum -y install elinks
elinks www.a.org elinks www.b.org
火狐浏览器打开网站测试
动态站点 LAMP Linux系统-网站程序Apache-数据库MySQL-PHP中间件
1.部署论坛系统discuz (关闭防火墙)
安装LAMP
[root@localhost ~]yum -y install httpd mariadb-server mariadb php php-mysql gd php-gd [root@localhost ~]systemctl start httpd mariadb [root@localhost ~]systemctl enable httpd mariadb2.导入discuz网站源码 Discuz! 官方站 - PHP 开源论坛 - Powered by Discuz!
wget https://gitee.com/3dming/DiscuzL/attach_files/870709/downloadmkdir -p /webroot/discuz yum -y install unzip unzip Discuz_X3.4_SC_UTF8_20211022.zip cp -rf upload/* /webroot/discuz/ chown -R apache.apache /webroot/discuz/3.Apache配置虚拟主机 vim /etc/httpd/conf.d/discuz.conf
ServerName www.discuz.com documentRoot /webroot/discuz Require all granted systemctl restart httpd
4.准备数据库[root@localhost discuz]# mysql MariaDB [(none)]> create database discuz; MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | discuz | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec)5.在客户端测试,先做域名解析 C:WindowsSystem32driversetchosts中添加
192.168.31.134 www.discuz.com
在客户端打开网站 www.discuz.com
部署博客系统wordpress(关闭防火墙)
1.在WordPress官网下载压缩包 下载 | WordPress.org China 简体中文
通过xshell上传 rz 选择文件
2.导入源码
[root@localhost ~]# mkdir -p /webroot/wordpress [root@localhost ~]# unzip wordpress-5.8.1-zh_CN.zip [root@localhost ~]# cp -rf wordpress/* /webroot/wordpress/ [root@localhost ~]# chmod -R 777 /webroot/wordpress/3.虚拟主机配置 vim /etc/httpd/conf.d/wordpress.conf
ServerName www.wordpress.com ServerAlias wordpress.com documentRoot /webroot/wordpress Require all granted systemctl restart httpd
4.创建数据库
mysql
MariaDB [(none)]> create database wordpress;5.客户机
a.做域名解析C:WindowsSystem32driversetchosts
192.168.31.134 www.wordpress.com 192.168.31.134 wordpress.com在浏览器中打开www.wordpress.com



