网站服务
- 概念
UI的转变:B/S结构
Ui:用户的接口,窗口
b/s:浏览器的形式
HTML:超级 文本 标记 语言
网页:使用HTML、PHP、JAVA语言格式书写的文件
主页:网页中车呈现的第一个页面 名称 index
网站:多个网页组合而成的一台网站服务器
URL:统一的资源定位符 ,访问网站的地址(网址)
网站架构:LAMP
Linux +Apache +MySQL +PHP
系统 服务器程序 数据管理软件 中间软件
静态网站
Apache
Apache基础
- 官网:www.apache.org
- 软件包名:httpd
- 服务端口:80/tcp(http) 443/tcp(https)加密,安全网站
- 配置文件:/etc/httpd/conf/httpd.conf
- 子配置文件:/etc/httpd/conf.d/*.conf
- 主目录:/var/www/html 网站源代码默认位置
安装Apache网站
检查httpd是否安装 yum list | grep httpd httpd.x86_64
安装 yum –y install httpd
启动服务 systemctl start httpd
查看服务状态 systemctl status httpd
开机自启 systemctl enable httpd
关闭防火墙 systemctl stop firewalld
关闭selinux setenforce 0
查看版本 httpd -v
虚拟主机
虚拟主机VirtualHost
作用:在一台物理服务器上运行多个网站
分为以下三种类型
- 基于主机名:www.a.org
<VirtualHost *:80>
ServerName www.a.org
DocumentRoot /var/www/html
- 基于端口: 192.168.1.10:80
<VirtualHost *:81>
ServerName 192.168.184.128
DocumentRoot /var/www/html/b.org
- 基于ip:192.168.1.1
<VirtualHost *:80>
ServerName 192.168.184.128
DocumentRoot /var/www/html/c.org
网站项目不在默认为网站目录 /var/www/html下 注意要授权
<Directory " /c.org">
Require all granted
</Directory>
配置虚拟主机目标
在一台服务器上,实现两个网站的架设
网站域名(需要购买) 网站资源存放目录
www.a.org /var/www/html/a.org
www.b.org /b.org
这里需要关闭firewalld selinux
服务器配置
www.a.org站点设置
- 准备网站源码目录
Mkdir /var/www/html/a.org
Vim /var/www/html/a.org/index.html 输入网页的内容 - 创建a.orgd的网站配置文件
Vim /etc/httpd/conf.d/a.org.conf
<VirtualHost *:80> 某个虚拟主机
ServerName www.a.org 服务器的名字
DocumentRoot /var/www/html/a.org 网站的根目录
- 检测配置文件语法,重启服务
Httpd -t
Systenctl restart httpd
www.b.org站点设置
1.准备网站源码目录
Mkdir /b.org
Vim /b.org/index.html 输入网页内容
2. 创建b.orgde网站配置文件
#vim /etc/httpd/conf.d/b.org.conf 文件中输入以下内容
<VirtualHost *:80>
ServerName www.b.org
DocumentRoot /b.org
<Directory “/b.org”> 目录授权,仅在网站主目录非“/var/www/html”时操作
Require all granted 允许所有的“网站”的访问
3. 检测配置文件语法,重启服务
httpd –t 无报错 重启服务器
systemctl restart httpd
客户端
192.168.142.129
Linux客户端域名解析
Vim /etc/hosts
192.168.142.134 www.a.org 填写web服务器的IP
192.168.142.134 www.b.org 填写web服务器的IP
Linux客户测试网站可用性
字符测试: yum –y install elinks
Elinks www.b.org
图形测试:通过浏览器访问网址
动态站点
LAMP:linux系统-网站程序apache-数据库mysql-PHP中间件
-
基础环境
Vim /etc/selinux/config 永久关闭seLinux
Setenforce 0 临时关闭selinux
Systemctl stop firewallld 停止防火墙
Systemctl disable firewalld 开机禁用防火墙 -
安装LAMP
yum -y install httpd mariadb-server mariadb php php-mysql gd php-gd
安装网站-数据库服务器-数据库客户端-中间件-中间插件-图形库-php图形库
systemctl start httpd mariadb 启动网站和数据库
systemctl enable httpd mariadb 开机启动网站和数据库 -
安装Discuz
导入网站源码
wget http://download.comsenz.com/DiscuzX/2.5/Discuz_X2.5_SC_UTF8.zip
mkdir -p /webroot/discus
yum –y install unzip 安装解压工具
unzip Discuz_X2.5_SC_UTF8.zip 解压源码包
co –rf ipload/* /webroot/discus 把文件拷贝到创建的文件夹里
chown –R apache.apache /webroot/discus 授予权限
配置虚拟主机
Vim /etc/httpd/conf.d/discus.conf 修改配置文件
<VirtualHost *:80>
ServerName www.discuz.com 网址名字
DocumentRoot /webroot/discus
<Directory “/webroot/discuz”>
Require all granted
</Directory>
Systemctl restart httpd 重启服务
准备数据库
[root@localhost discuz]# mysql
MariaDB [(none)]> create database discuz (库名)
Show databases 查看所有库;
注意:切记创建数据库要再敲一遍,检查是否创建成功
客户机域名解析
Vim /etc/hosts
Ip地址 www.discuz.com
10.0.128.118 www.a.org
部署博客、网上商城、网校系统等 大致一样!