1.概念
//前言
UI的转变:B/S架构
//名词
HTML:HyperText Markup Language
超级 文本 标记 语言
网页:使用HTML,PHP,JAVA语言格式书写的文件
主页:网页中呈现用户的第一个页面
网站:多个网页组合而成
URL:www.baidu.com
Uniform Resource Locator
统一资源定位符
访问网站的地址
//网站架构
LAMP:Linux + Apache + MySQL + PHP
系统+服务器软件+数据管理软件+中间软件
2.静态网站
//Apache
Apache(音译为阿帕奇)是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一
//Apache基础
Apache官网:www.apache.org
软件包名称:httpd
服务端口:80/tcp(http) 443/tcp(https)
配置文件:/etc/httpd/conf/httpd.conf
子配置文件:/etc/httpd/conf.d/*.conf
//安装Apache
#yum install -y httpd 安装
#systemctl start httpd 启动
#systemctl status httpd 查看服务状态
#systemctl enable httpd 开机自启动
#systemctl stop firewalld 关闭防火墙
#setenforce 0 关闭selinux
#httpd -v 查看版本
//虚拟主机
目的:虚拟主机VirtualHost,在一台物理服务器上运行多个网站
类型:基于主机名:www.a.com www.b.com
配置虚拟主机目标:在一台服务器上,实现两个网站的架设
网站域名 网站资源存放目录
www.a.com /var/www/html/a.org
www.b.com /b.org
注意关闭firewalld和selinux
服务器:
www.a.org站点设置:
准备网站源码(网页)目录:#mkdir /var/www/html/a.org
#vim /var/www/html/a.org/index.html
This is a test for www.a.org!
创建a.org的网站配置文件:#vim /etc/httpd/conf.d/a.org.conf
<VirtualHost *:80>
ServerName www.a.org //名字
DocumentRoot /var/www/html/a.org //网站的根目录
</VirtualHost>
检测配置文件语法,重启服务:#httpd -t
#systemctl restart httpd
www.b.org站点设置:
准备网站源码(网页)目录:#mkdir /b.org
#vim /b.org/index.html
This is a test for www.b.org!
创建a.org的网站配置文件:#vim /etc/httpd/conf/b.org.conf
<VirtualHost *:80>
ServerName www.b.org
DocumentRoot /b.org
</VirtualHost>
<Directory "/b.org"> //如果没有在指定目录下,需要授权
Require all granted
</Directory>
检测配置文件语法,重启服务:#httpd -t
#systemctl restart httpd
客户端:
Linux客户端域名解析:#vim /etc/hosts
web服务器ip 网站名
Linux客户端测试网站可用性:字符测试:elinks
图形测试:浏览器访问网站名
//防火墙
firewalld简介:保护互联网对服务器的影响
selinux:保护服务器内部程序(ftp)对内部文件(/var/ftp)的访问
firewalld临时关闭:systemctl stop firewalld
firewalld永久关闭:systemctl disable firewalld
firewalld状态查看:systemctl status firewalld
selinux临时关闭:setenforce 0
selinux永久关闭:vim /etc/selinux/config,修改如下内容SELINUX=disabled
selinux状态查看:getenforce(enforcing开启,permissive放行,disable关闭)
3.动态网站
//部署论坛系统discuz
基础环境:关闭firewalld和selinux
安装LAMP:#yum install -y httpd mariadb-server mariadb php php-mysql gd hph-gd
#systemctl start httpd mariadb
#systemctl enable httpd mariadb
安装Discuz:
导入discuz网站源码:
#wget https://gitee.com/Discuz/DiscuzX/repository/archive/v3.5.zip
#mkdir /webroot/discuz
#unzip v3.5.zip -d /webroot/discuz/
#chown -R apache.apache /webroot/discuz/
Apache配置虚拟主机:
#vim /etc/httpd/conf.d/discuz.conf
<VirtualHost *:80>
ServerName www.discuz.com
DocumentRoot /webroot/discuz/DiscuzX-v3.5/upload
</VirtualHost>
<Directory "/webroot/discuz/DiscuzX-v3.5/upload">
Require all granted
</Directory>
#systemctl restart httpd
准备数据库:
#mydql
MariaDB [(none)]> create database discuz;
安装discuz[任何client]:如下图
客户端测试:
Linux客户端域名解析:#vim /etc/hosts
服务器IP www.discuz.com
Linux客户端测试网站可用性:字符测试:elinks
图形测试:浏览器访问www.discuz.com
本次使用的是discuz3.5版本,有可能linux自带的php版本不满足discuz的要求,下面是解决方案