文章目录

  • linux网站服务
  • 概念
  • 名词
  • 网站架构
  • 静态站点
  • Apache
  • 虚拟主机
  • 动态网站
  • 部署论坛系统discuz
  • 部署博客系统wordpress


linux网站服务

概念

名词
  • HTML
    HyperText Markup Language超文本标记语言。
  • 网页
    使用HTML,PHP,JAVA语言格式书写的文件,网页就是服务器把html文件拷贝到计算机上面
    下载网页文件
sz 要下载的网页文件
sz index.html
  • 主页
    网站中给用户呈现的第一个网页称为主页
  • 网站
    多个网页组合而成的一台网站服务器
  • URL
    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# 网站源代码放置的位置
  • 查看httpd的版本
httpd -v
虚拟主机

虚拟主机是在一台物理服务器上运行多个网站,它基于主机名称

  • 配置虚拟主机的目标
    在一台服务器上,实现两个网站的架设,网站的域名就是网站资源存放的目录
    在网站服务器上创建网站资源存放的目录
mkdir /var/www/html/a.org

创建html文件并且写入内容

vi /var/www/html/a.org/index.html
  • 创建a.org的网站配置文件
vi /etc/httpd/conf.d/a.org.conf

写入以下内容:

<VirtualHost *:80># 某一个虚拟的主机,*代表的服务器的IP地址,80代表端口
ServerName www.a.org
DocumentRoot /var/www/html/a.org# 网站内容存放的地址
</VirtualHost>
<Directory "/var/www/html/a.org">
Require all granted# 授权
</Directory>
  • 重启服务
systemctl restart httpd
  • 检查配置文件的语法
httpd -t
  • 使用centos7客户端进行访问
vim /etc/hosts

编辑文件的格式如下:

192.168.83.150 www.a.org

可以在浏览器中输入www.a.org进行查看网页,也可以使用elinks URL查看网页

动态网站

部署论坛系统discuz
  • 基础环境
systemctl stop firewalld 
systemctl disable firewalld
  • 安装LAMP
    安装应用程序
yum install -y httpd mariadb-server mariadb php php-mysql gd php-gd

启动应用程序

systemctl start httpd mariadb
systemctl enable httpd mariadb
  • 安装Discuz
    在网上下载discuz源码包
    创建文件夹
mkdir -p /webroot/discuz

下载解压工具

yum install -y unzip

解压zip压缩包

unzip ./*.zip
cp -rf upload/* /webroot/discuz/

对文件进行授权

chown -R apache.apache /webroot/discuz

编写httpd的配置文件

vi /etc/httpd/conf.d/discuz.conf
<VirtualHost *:80>
ServerName www.discuz.com
DocumentRoot /webroot/discuz
</VirtualHost>
<Directory "/webroot/discuz">
Require all granted
</Directory>

重启httpd服务

systemctl restart httpd

准备数据库

mysql

linux网站服务_配置文件

创建一个discuz的数据库

create database discuz;
# 创建 数据库 名称叫discuz

查看创建好的数据库

show databases;

linux网站服务_html_02

  • 客户端测试
    客户端测试时,添加域名解析
vi /etc/hosts

写入内容

192.168.83.150 www.discuz.com

打开浏览器在url中输入www.discuz.com,你会看到安装向导,这就是论坛的系统部署。

部署博客系统wordpress

创建文件夹

mkdir -p /webroot/wordpress

解压wordpress的压缩包

unzip wordpress的压缩包

文件拷贝

cp -rf wordpress/* /webroot/wordpress/

改变权限

chown -R apache.apache /webroot/wordpress/

编写配置文件

vim /etc/httpd/conf.d/wordpress.conf

写入内容:

<VirtualHost *:80>
ServerName www.wordpress.com
ServerAlias wordpress.com
DocumentRoot /webroot/wordpress
</VirtualHost>
<Directory "/webroot/wordpress">
Require all granted
</Directory>

重启httpd程序

systemctl restart httpd

进入mysql中

mysql

准备一个博客wordpress的数据库

create database wordpress;

域名解析

vi /etc/hosts
192.168.83.150 www.wordpress.com