第17章—网站服务

1.概念
1.前言:UI的转变:B/S架构


2.名词:
HTML:HyperText Markup Language 超级 文本 标记 语言
网页:使用HTML,PHP,JAVA语言格式书写的文件。
主页:网页中呈现用户的第一个页面。
2 9 = p Q Z站:多个网页组9 I x # v k e h合而成的一台网站服务
URL:http://www.baidu.com:80/1.html
ftp://192.168.142.143:21/1.txt
Uniform Resource Locator
统一资源定位符
访问网站的地址


3.网站架构:
LAMP:
Lb 3 Y Jinux + Apache + MySQL + PHP
系统+服务器程序+o B c R B t Z !数据管理软件+中间软件
2.静态站点
1.Apach` ( ie:建议使用2.4及以上的版本 第17章—网站服务第17章—网站服务


2y * S 6 u S 1.Apache基础:
Apache官网: www.apache.org
软件包名称: httpd
服务端| w X & g Y f ]口: 80/tcp(http) 443/tcp(httpn - Ks)+ E y T w @
配置文件: /etc/httpd/conf/httpd.conf
配置文件:/etc/httpd/conf.d/*.conf
主目录:/var/www/html网站源代码默M N W 8认位置


3.安装Apache:yum -y install hf z 4 2 I gttpd安装第17章—网站服务
systemctl start ht, v 9 g g y . :tpd启动第17章—网站服务
systemctl status httpd查看服务状态

systemctl enable httpd开机自启
第17章—网站服务
systemctl stop firewalld关闭防火墙
第17章—网站服务
setenforce 0关闭selinux
第17章—网站服务
httpd -v查看版本
第17章—网站服务


4.虚拟主机:
目的:
虚拟主机VirtualHost
作用:在一台物理服务器上运行多个网站
类型:
基于主机名
www.a.org
www.b.org
配置虚拟主机目| F - $ c B标:
在一台服务器上,实现两个网站的架设
网站域名 网站资源存放目录
www.a.org /var/www/html/a.org
www.b.org /b.org
注意关闭firewalld和selinux
环境:
10.8.162.165web服务器
10.8= F w ` ] F (.162.88客户机
192.168.142.1真机
同上一台linux客户机
服务器:10.8.162.165
1f , ) O c D.准备网站源码:mkdir /var/www/html/a.org
第17章—网站服务
vim /var/www/html/a.org/indeg d m g t # b )x.ht= v P G G ;ml 输入397039762
第17章—网站服务
vim /etc/httpd/conf.d: I G K P/a.org.conf第17章—网站服务
httpd -t 重启服务# sn T M ; =ystemctl restart httpd 第17章—网站服务
www.b.org站点设置
1.准备网站源码目录:
mkdir /b.org
第17章—网站服务
vim /b.org/index.html第17章—网站服务
2.创建b.org的网站配置文件
vim /etc/httpd/_ } 3 tconf.d/b.orB : * L % ] s 9g.c4 Y x 5 P ^ + % ?onf
第17章—网站服务
httpd -t第17章—网站服务 #重启systemctl restart httpd
第17章—网站服务
Linux客户端域名解析
vim /etc/hosts
10.8.162q u $.88 www.a.org填写web服务器的IP

Windows客户端域名解析第17章—网站服务

3.动态站点
1.LAMP:linux系统-网站程序apache-数据库mysql-PHP中间件


2.部署论坛系统discuz:
logo: 第17章—网站服务开源论坛代码服务社区
一、基础环境
se] ~ : % i ) H v ud -ri '/^SELINUX=/cSELIT 1 ` .NUX=disabled' /e第17章—网站服务
setenforce 0
systemctl stop firewalldW r 6 w - , w 3 7.service关闭防火墙
systemctlg E D 8 D T disable firewalld.service 开机不自启
二,安装LAMP:
yB ] ~ yum -y install htT P -tpd mariadb-server mariadb php php-mysql gd php-gd第17章—网站服务
设置重启systemctl restart httpd mariadb
设置开机自启:systemctl enable htppd martadb第17章—网站服务
三、安装Discuz!

  1. 导入discuzY : t 5 + O 1网站源码
    wget http://dt 2 n r !ownloS J c : P 1ad.comsenz.com/DiscuzX/2.5/Discuz_X2n I V.5_SC_UTF8.zip
    第17章—网站服务
    mkdir /webroot/boke第17章—网站服务
    yum install -y unzip第17章—网站服务
    解压缩unzip Discuz_X2.5_SC_UTF8.zip
    cp -rf upload/* /webroot/boke
    第17章—网站服务
    chown -R apache:az D Qpache /webroot/boke
    第17章—网站服务
    Apache配置虚拟主机:vim /etc/httpd/conf.d/boke.cI O V e s 1 - B oonf
    systemctl restarh Y * ( H v #t httpd
    第17章—网站服务
    mysql第17章—网站服务第17章—网站服务
    3.部署博客系统workpress:
    logo: 第17章—网站服务
    一、基础环境[已完成]
    sedV S % . = ! 7 1 -ria G 0 5 '/^SELINUX=/cSELINUX=disabled' /etc/selz J q U ` 7inux/c3 N M ( S 6 ionfig
    setenforce 0
    systemctl stop firewalld.serh G Ivice
    systemctl disable firewalld.service`* y 4 ! _ { ```

    二、安装LAMP[已完成]
    yum -y install httpd mariadb-server mariadb php php-mysql gd php-gd
    systemctl start httpd mariadb
    systemctl enable httpd mariadb

    Apache 配置虚拟主机:
    vim /etc/httpd/conf.d/bk.conf
    <VirtualHost *:83>
    ServerName wQ V F 7 e 8 lww.wordpress.com
    DocumentRooM g d B ot /webroot/bk
    </VirtualHost>
    <Directory "/webroot/bk">
    Require all granted
    </Directory>

    导入wordpress网站源码:
    mkdir -p /webroot/bk
    unzip wordpress-4.9.4-zh_CN.zip
    cp -rf wordpress/* /webroot/bk
    chown -R aK J ~ q Zpache:apache /webroot/bk
    systemctl restart httpd
    mysql
    MariaDB [(none)]> create database wordpress ;

    5.不是网校系统edusoho:

    一,基础环境:
    sed -ri '/^SELINUX=/cSELINUX=disabo U ,led' /etc/selinux/config
    setenforce 0
    systemctl stop firewalld.si F - 0 /ervice
    systemctl disable firewalld.sD A rervice

    二,epel源:
    yum i~ S I F [ @ C | Dnstall -y epel-release

    ![](https://s4.51cto.com/images/blog/202008/21/27dd14cbd77c50d04428f4ebdb5e56ef.png)

    yum -y install bash-completion httpd php php-cli php-curl php-fpm php-intl php-mcrypt php-mysql php-gdV Q q , e 7 php-mbstring php-xml php-dom ma% m e S h S 6riadb-server mariadb

    ![](https://s4.51cto.com/images/blog + V E ) p/202008/2H ? p +1/fd4369db56c5fbd9228f09ba76d51869O ) k G = + o b T.png)

    systemctl start httpd mariadb

    ![](https:9 V 2//s4.51cto.com/images/blog/202008/21/a514ae963ee5153bcd382e52c73e864a.png)

    #mysql
    MariaDB [(none)]> create database wx;

    ![](htt% Q K gps://s4.51cto.com/images/blog/202008/21/2a23b69ca6dac7a27815e2941542a512.pngR l o - ( B : f)
    设置上传限制:

    网校的视频文件比较大,将默认的2M上传改大u j P o z些。
    vim /etc/php.ini
    post_max_size = 1024M
    memory_limit = 1024M
    upload_max_filI v = + #esize = 1024M
    date.timezone = Asia/ShangHai

[可选]
vim /etc/php-fpm.d/www.conf
listen.owner = apache
listen.group = apache
listen.mode = 0666

sy3 } j jstemctl stax q prt php-fpm
systemctl enable php-fpm

![](https://s4.51cto.com/images/blog/202008/21/6e231ecf71a9361bae978bf421cb26d7.png)
六,上传源码

wget http://downloadQ i s.edusohow & m - s , b *.com/edusoho-7.5.12.tar.gz
tar xf edusoho-7.5.12.tar.gz
mkdir -p /webroot/edusoho
cp -rf edusoho/* /webroot/edusoho
chown -R apache.apache /webroot/o _ 7 O # X [edusoho

![](https:/u n A B 9/s4.51cto.com/images/blog/202008/21/9f19d79834af15108c725c152830e782.png)![](https://s4.51cto.com/images/blog/202008/21/9b4982` W Y89a103b307Q H P 6 * , h / fe06d0bc& ! G 1 v ~ : ~ x2a2s 0 { Z 4 s 4 ( kfa6e28.png)
七,设置虚拟主机:

vim /etc/httpd/conf.d/wx.conf
<Virtua % J ! 1 p ]alHost *s m H H:84>
ServerName www.edusoho.com
DocQ A ] b 6 h # ,umentRoot /webroot/wx/web
</VirtualHost>

<Directory "/webroot/wx/web">
Require all granted
</Directory>

![](https://s4.51cto.com/images/blog/202008/21/b7369995279ac6eab7b90d891f2b95c7.png)
主配置文件添加端口:

vim /etc/httpd/conf* B } c $ G/httpd.conf


![](https://s4.51cto.com/images/blog/202008/22/549707dfa5e14afe7a2949f926a280d2.pnY : ~ + D K W i qg)
在阿里云上添加端口[ @ b ! q![](https://s4.51cto.com/images/~ ^ _ * 3 N 3 !blog/202w U i F 2 o 6008/22/a9064e9c6b661ed8ce053affbe6bd5e6.png)