FCGI模式编译安装LAMP平台以及搭建XCAHCE部署BBS论坛

简介:

PHP的工作模式:

PHP在lamp环境下共有三种工作模式:CGI模式Apache模块FastCGI模式。CGI模式下运行PHP,性能不是很好。作为Apache的模块方式运行,在这之前编译安装lamp已经介绍过了。FastCGI的方式和Apache模块的不同点在于:FastCGI方式PHP是一处独立的进程,所有PHP子进程都由PHP的一个叫做php-fpm的组件负责管理;而Apache模块化方式运行的PHP,则是Apache负责调用PHP完成工作。PHP的FastCGI方式性能要比Apache模块化方式强很多,今天我们以FastCGI方式编译安装lamp。

FastCGI工作的机制:

首先客户端发起请求,请求分为2种,一种是静态请求它可以直接由Apache直接响应返回;另一种是动态的请求,如其中包含中php或者Perl这种脚本解释性语言,则由Apache服务器通过fastcgi协议调用php服务器执行并返回给Apache由Apache返回解释执行后的结果(返回给客户端),如果这个过程中涉及到对数据的操作,此时php服务器还会还会通过mysql协议调用mysql服务器。


实验环境:

Linux

Web服务器

Php

Mysql数据库

xcache

Centos7.2

Httpd-2.4.23

php-5.4.26

Mysql5.7

xcache-3.1.0

主机规划:

一共是三台主机,操作系统都是centos7.2系统,动态获取ip地址,网段在192.168.197.0/24

分配如下:

1台httpd服务器:192.168.197.152

1台PHP服务器:192.168.197.166

1台MySQL服务器:192.168.197.163

接下来开始编译安装LAMP:

本人声明:由于之前已经编译安装好Apache服务,所以这里不再一一介绍:

可以点击下面的链接查看Apache详细安装的过程:

Apache安装过程http://blog.csdn.net/kangshuo2471781030/article/details/79171344

本人声明:由于之前已经编译安装好MySQL服务,所以这里不再一一介绍:

可以点击下面的链接查看mysql详细安装的过程以及安装方式:

MySQL安装过程http://blog.csdn.net/kangshuo2471781030/article/details/79088357


一、FastCGI方式安装PHP


(1.)解决依赖关系(安装php相关依赖包)

[root@kang ~]#  yum -y install libxml2-devel libcurl-devel openssl-devel bzip2-devel



(2.)安装libmcrypt

可以到官网wget下载libmcrypt:

libmcrypt下载:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

[root@kang ~]# tar zxf libmcrypt-2.5.7.tar.gz 
[root@kang ~]# cd libmcrypt-2.5.7/
[root@kang libmcrypt-2.5.7]#  ./configure --prefix=/usr/local/libmcrypt && make && make install


(3.)编译安装PHP

[root@kang ~]# tar zxf php-5.6.27.tar.gz 
[root@kang ~]# cd php-5.6.27/
[root@kang php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2--enable-maintainer-zts


[root@kang php-5.6.27]# make && make install




相关选项的解释:

--prefix=/usr/local/php5.6//安装位置

--with-mysql=mysqlnd //支持mysql

--with-pdo-mysql=mysqlnd//支持pdo模块

--with-mysqli=mysqlnd//支持mysqli模块

注意:上面的三选项的作用:数据库与php不在一个服务器上,指定此种方式,安装数据库连接驱动

--with-openssl//支持openssl模块

--enable-fpm//支持fpm模式

--enable-sockets//启用socket支持

--enable-sysvshm//启用系统共享内存支持

--enable-mbstring//多字节字串、像我们的中文就是多字节字串

--with-freetype-dir//支持freetype、就要装freetype-devel、跟字体相关的、字体解析工具

--with-jpeg-dir

--with-png-dir

注意:上面的二选项的作用:处理jpeg、png图片的、php可以动态生成jpeg图片

--with-zlib//是个压缩库、在互联网传输时用来压缩传输的
--with-libxml-dir=/usr//这个libxml是用来解析xml的、指定/usr下
--enable-xml   //支持xml的
--with-mhash//支持mhash
--with-mcrypt=/usr/local/libmcrypt //libmcrypt-devel这个程序包所指定的
--with-config-file-path=/etc//指定配置文件的存放路径的
--with-config-file-scan-dir=/etc/php.d  //配置文件扫描路径
--with-bz2  //支持BZip2

为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项,如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。

(4.)提供php配置文件
[root@kang php-5.6.27]# cp php.ini-production /etc/php.ini
(5.)为php-fpm提供脚本

[root@phpserver php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@phpserver php-5.6.27]# chmod +x /etc/init.d/php-fpm 
[root@phpserver php-5.6.27]# chkconfig --add php-fpm
[root@phpserver php-5.6.27]# chkconfig php-fpm on
(6.)提供php-fpm配置文件并编辑:

[root@kang ~]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
[root@kang ~]# vim /usr/local/php5.6/etc/php-fpm.conf
修改内容如下:

pid = run/php-fpm.pid
listen = 192.168.197.166:9000
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35


(7.)保存退出,启动php-fpm服务:


注意:关闭防火墙或放行9000端口

[root@phpserver ~]# firewall-cmd --permanent --add-port=9000/tcp
success
[root@phpserver ~]# firewall-cmd --reload
Success

(8.)在PHP服务器上新建虚拟主机目录用于存放网页文件

[root@phpserver ~]# mkdir -p /var/www/benet

二、至此php安装配置完毕,下面配置apache通过fastcgi协议调用php


(1.)在Apache2.4以后已经专门有一个模块针对FastCGI的实现,此模块为mod_proxy_fcgi.so,它其实是作为mod_proxy.so模块的扩充,因此,这两个模块都要加载

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

[root@kang ~]# vim /usr/local/http-2.4.23/conf/httpd.conf 

(2.)查看proxy模块是否加载

[root@kang ~]# apachectl -M | grep proxy

(3.)建立一个目录作为虚拟主机的家目录

root@www ~]# mkdir -p /var/www/benet
(4.)编辑主配置文件httpd.conf,开启虚拟主机,启用Include conf/extra/httpd-vhosts.conf

[root@kang ~]# vim /usr/local/http-2.4.23/conf/httpd.conf 

同时定位 AddType;添加下面两行:让apache能识别php格式的页面

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

并且定位至DirectoryIndex:支持php格式的主页

DirectoryIndex index.php index.html #添加index.php(最好添加在最前面)

(5.)配置虚拟主机支持使用fcgi

[root@kang ~]# vim /usr/local/http-2.4.23/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@benet.com
    DocumentRoot "/var/www/benet"
    ServerName www.benet.com
    ServerAlias benet.com
    ErrorLog "logs/benet.com-error_log"
    CustomLog "logs/benet.com-access_log" common
    ProxyRequests Off
ProxyPassMatch  ^/(.*\.php(/.*)?)$  fcgi://192.168.31.141:9000/var/www/benet/$1
<Directory "/var/www/benet">
Options  FollowSymLinks
       AllowOverride None
       Require all granted
</Directory>
</VirtualHost>

(6)保存退出,重启Apache服务!!!

[root@kang ~]# service  httpd restart

相关参数解释:

ProxyRequests off #关闭正向代理

ProxyPassMatch:把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI,所以这里直接在fcgi://192.168.31.141:9000后指明了这两个参数,其它的参数的传递已经被mod_proxy_fcgi.so进行了封装,不需要手动指定。特别注意的是,红色字体部分需要与<VirtualHost >中的 DocumentRoot后的路径一致

ProxyPassMatch:只有满足特定正则模式的内容才会匹配并执行此规则,这里的模式是,^/(.*\.php(/.*)?)$
从网站(虚拟主机<VirtualHost >的根目录开始,匹配任何以 .php 结尾,或者在 .php 之后紧跟一个 / 再跟别的内容的路径。

^ (caret) 和 $ (dollar)标志要匹配的路径的开始和结束

( )括号里的内容可以用 $1 来表示,以方便后面引用它。

fcgi:// 192.168.197.166:9000通过mod_proxy_fcgi 来转发的代理,使用 fastCGI 协议,转到 PHP-FPM 监听的端口。

/path/to/your/documentroot/

非常重要!必须与虚拟主机的路径匹配,且必须是对应 php 文件在操作系统中的绝对路径。否则会找不到文件。

$1可以从原始请求扩展成整个请求路径的变量,这里指代前面( ) 里面匹配的那个路径(uri)

补充:Apache httpd 2.4以前的版本中,要么把PHP作为Apache的模块运行,要么添加一个第三方模块支持PHP-FPM实现。


三、测试LAMP环境:


(1.)在mysql主机上创建用于授权php服务器连接到mysql的账户

mysql> grant all on *.* to testuser@'%' identified by 'pwd123';

注意防火墙要允许mysql连接。

[root@kang ~]# firewall-cmd --permanent --add-port=3306/tcp
success
[root@kang ~]# firewall-cmd  --reload 
success
[root@kang ~]# 
(2.)在php服务器上的/var/www/benet目录下创建.php(PHP和MySQL)的测试页:

[root@kang ~]# cd /var/www/benet/
[root@kang benet]# vim index.php vim test1.php

<?php
phpinfo();
?>
<?php
$link=mysql_connect('192.168.197.163','testuser','pwd123');
if ($link)echo "connection success......";
mysql_close();
?>
(3.)测试:访问PHP服务与MySQL服务的测试页



看到上面两个测试页说明apache、php、mysql之间可以协同工作了。

至此LAMP环境搭建成功!!!


四、ab压力测试(Apache自带的压力测试工具)


简介:

网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环。只有让服务器处在高压情况下,才能真正体现出软件、硬件等各种设置不当所暴露出的问题。性能测试工具目前最常见的有以下几种:ab、http_load、webbench、siege。今天我们专门来介绍ab。ab是apache自带的压力测试工具。ab非常实用,它不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试。比如nginx、tomcat、IIS等。

下面我们开始介绍有关ab命令的使用:

1.ab的原理

ab是apachebench命令的缩写。

ab的原理:ab命令会创建多个并发访问线程,模拟多个访问者同时对某一URL地址进行访问。它的测试目标是基于URL的,因此,它既可以用来测试apache的负载压力,也可以测试nginx、lighthttp、tomcat、IIS等其它Web服务器的压力。

ab命令对发出负载的计算机要求很低,它既不会占用很高CPU,也不会占用很多内存。但却会给目标服务器造成巨大的负载,其原理类似CC攻击。自己测试使用也需要注意,否则一次上太多的负载。可能造成目标服务器资源耗完,严重时甚至导致死机。

2.ab的安装

(1.)ab的安装非常简单,如果是源码安装apache的话,那就更简单了。apache安装完毕后ab命令存放在apache安装目录的bin目录下。如下:

/usr/local/http2.4.23/bin/ab

(2.)如果apache 是通过yum的RPM包方式安装的话,ab命令默认存放在/usr/bin目录下。如下:

which ab

(3.)注意:如果不想安装apache但是又想使用ab命令的话,我们可以直接安装apache的工具包httpd-tools。如下:

yum -y install httpd-tools
rpm -ivh httpd-tools --nodeps

(4.)查看ab是否安装成功,可以切换到上述目录下,使用ab –V命令进行检测。如下:

[root@www ~]# /usr/local/http-2.4.23/bin/ab -V
This is ApacheBench, Version 2.3 <$Revision: 1748469 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

3.ab参数说明

有关ab命令的使用,我们可以通过帮助命令进行查看。如下:

[root@cent05 ~]# ab--help

下面我们对这些参数,进行相关说明。如下:

-n:在测试会话中所执行的请求个数(即总请求数)。
-c:一次产生的请求个数(即并发用户数)。
[root@kang ~]# ab -n 1000 -c 700  http://192.168.197.167/index.html



相关参数详解:

Document Path:          /index.html    #请求的资源
Document Length:        312 bytes  #HTTP响应数据的正文长度
Concurrency Level:      500# 并发个数(并发用户数)
Time taken for tests:   1.452 seconds #所有这些请求处理完成所花费的时间 
Complete requests:      10000# 完成请求数
Failed requests:        0 #失败的请求数
Total transferred:      4760000 bytes  #表示所有请求的响应数据长度总和,包括每个HTTP响应数据的头信息和正文数据的长度。注意这里不包括HTTP请求数据的长度,仅仅为web服务器流向用户PC的应用层数据总长度。 
HTML transferred:       3120000 bytes  # 表示所有请求的响应数据中正文数据的总和,也就是减去了Total transferred中HTTP响应数据中的头信息的长度。
Requests per second:    7530.93 [#/sec] (mean) #吞吐量-每秒请求数。
计算公式:Complete requests/Time taken for tests
Time per request:       66.393 [ms] (mean) #用户平均请求等待时间,计算公式:Time token for tests/(Complete requests/Concurrency Level)。
Time per request:       0.133 [ms] (mean, across all concurrent requests)  #服务器平均请求等待时间,计算公式:Time taken for tests/Complete requests。
Transfer rate:          3500.71 [Kbytes/sec] received  #表示这些请求在单位时间内从服务器获取的数据长度,计算公式:Total trnasferred/ Time taken for tests,这个统计很好的说明服务器的处理能力达到极限时,其出口宽带的需求量。(即平均每秒网络上的流量)
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:       10   27   7.3     27      48
Processing:     4   37  36.5     32     439
Waiting:        2   27  37.0     21     435
Total:         30   64  37.6     60     470

Percentage of the requests served within a certain time (ms)
  50%     60
  66%     63
  75%     64
  80%     66
  90%     71
  95%     76
  98%     89
  99%    261
 100%    470 (longest request)
这部分数据用于描述每个请求处理时间的分布情况,比如以上测试,80%的请求处理时间都不超过66ms,这个处理时间是指前面的Time per request,即对于单个用户而言,平均每个请求的处理时间。


(1.)继续压力测试
      我们再来进行一次压力测试,此时并发用户数为900,其他条件不变,查看两次测试结果的吞吐量差别




通过两次的压力测试,可以发现第二次要比第一次并发量高很多,至此通过压力测试来调整并发量对Apache服务优化来说尤为重要!!!

4.ab性能指标

在进行性能测试过程中有几个指标比较重要:

(1.)吞吐率(Requests persecond

服务器并发处理能力的量化描述,单位是reqs/s,指的是在某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率。记住:吞吐率是基于并发用户数的。

这句话代表了两个含义:

a、吞吐率和并发用户数相关
b、不同的并发用户数下,吞吐率一般是不同的

计算公式:总请求数/处理完成这些请求数所花费的时间,即

Request per second=Complete requests/Time taken for tests

必须要说明的是,这个数值表示当前机器的整体性能,值越大越好。

(2.)并发连接数(The number ofconcurrent connections

并发连接数指的是某个时刻服务器所接受的请求数目,简单的讲,就是一个会话。

(3.)并发用户数(Concurrency Level

要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。

(4.)用户平均请求等待时间(Time per request

计算公式:处理完成所有请求数所花费的时间/(总请求数/并发用户数),即:

ime per request=Time taken for tests/(Complete requests/Concurrency Level)

(5.)服务器平均请求等待时间(Time perrequest:across all concurrent requests

计算公式:处理完成所有请求数所花费的时间/总请求数,即:

Time taken for/testsComplete requests

可以看到,它是吞吐率的倒数。

同时,它也等于用户平均请求等待时间/并发用户数,即

Time per request/Concurrency Level


五、CentOS7.2下安装php加速软件Xcache(在php主机上完

成下面的操作)

说明:

php安装目录:/usr/local/php5.6

php.ini配置文件路径:/etc/php.ini

php网页根目录:/var/www/benet


(1.)安装xcache

可到官方网站下载: 点击打开链接  wgethttp://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz

[root@kang ~]# tar zxf xcache-3.2.0.tar.gz 
[root@kang ~]# cd xcache-3.2.0/
[root@kang xcache-3.2.0]# /usr/local/php5.6/bin/phpize

[root@kang xcache-3.2.0]#  ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=/usr/local/php5.6/bin/php-config

[root@kang xcache-3.2.0]# make && make install


注意:安装完成之后,出现下面的界面,记住以下路径,后面会用到

/usr/local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/

(2.)创建xcache缓存文件,并给于权限

[root@kang ~]#  touch /tmp/xcache
[root@kang ~]# chmod 777 /tmp/xcache
(3.)拷贝xcache后台管理程序到网站根目录
[root@kang ~]# cd xcache-3.2.0/
[root@kang xcache-3.2.0]# cp -r htdocs/ /var/www/benet/xcache
(4.)配置php支持xcache

vi / etc/php.ini #编辑配置文件,在最后一行添加以下内容
[xcache-common]
extension = /usr/local/php5.6/lib/php/extensions/no-debug-zts-20131226/xcache.so
[xcache.admin]
xcache.admin.enable_auth = Off
[xcache]
xcache.shm_scheme ="mmap"
xcache.size=60M
xcache.count =1
xcache.slots =8K
xcache.ttl=0
xcache.gc_interval =0
xcache.var_size=64M
xcache.var_count =1
xcache.var_slots =8K
xcache.var_ttl=0
xcache.var_maxttl=0
xcache.var_gc_interval =300
xcache.test =Off
xcache.readonly_protection = Off
xcache.mmap_path ="/tmp/xcache"
xcache.coredump_directory =""
xcache.cacher =On
xcache.stat=On
xcache.optimizer =Off
[xcache.coverager]
xcache.coverager =On
xcache.coveragedump_directory =""

(5)保存退出,重启PHP服务。

[root@kang ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

(5.)将xcache目录拷贝到apache主机的网页文档目录下

[root@kang ~]# scp -r /var/www/benet/xcache/ root@192.168.197.167:/var/www/benet/

(6.)测试在Apache服务器上用浏览器打开网站根目录下面的xcache

http://http://192.168.197.167/xcache可以看到如下页面:


至此,php加速软件Xcache安装配置完成!!!


(7.)执行ab压力测试:


执行第一次压力测试:

[root@kang ~]# ab -c 100 -n 1000 http://192.168.197.167/index.php
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.197.167 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.23
Server Hostname:        192.168.197.167
Server Port:            80

Document Path:          /index.php
Document Length:        84463 bytes

Concurrency Level:      100
Time taken for tests:   2.470 seconds
Complete requests:      1000
Failed requests:        229
   (Connect: 0, Receive: 0, Length: 229, Exceptions: 0)
Write errors:           0
Total transferred:      84637518 bytes
HTML transferred:       84466518 bytes
Requests per second:    404.78 [#/sec] (mean)
Time per request:       247.048 [ms] (mean)
Time per request:       2.470 [ms] (mean, across all concurrent requests)
Transfer rate:          33456.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   2.1      0       9
Processing:    23  235  34.6    238     315
Waiting:        7  227  33.9    229     286
Total:         25  236  33.5    239     316

Percentage of the requests served within a certain time (ms)
  50%    239
  66%    246
  75%    251
  80%    255
  90%    264
  95%    271
  98%    280
  99%    287
 100%    316 (longest request)


执行第二次压力测试

[root@kang ~]# ab -c 100 -n 1000 http://192.168.197.167/index.php
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.197.167 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.23
Server Hostname:        192.168.197.167
Server Port:            80

Document Path:          /index.php
Document Length:        84462 bytes

Concurrency Level:      100
Time taken for tests:   5.742 seconds
Complete requests:      1000
Failed requests:        916
   (Connect: 0, Receive: 0, Length: 916, Exceptions: 0)
Write errors:           0
Total transferred:      84636138 bytes
HTML transferred:       84465138 bytes
Requests per second:    174.16 [#/sec] (mean)
Time per request:       574.183 [ms] (mean)
Time per request:       5.742 [ms] (mean, across all concurrent requests)
Transfer rate:          14394.80 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   3.3      0      15
Processing:   124  528 131.1    532    1532
Waiting:      115  486 116.8    492    1231
Total:        138  529 129.4    532    1532

Percentage of the requests served within a certain time (ms)
  50%    532
  66%    591
  75%    617
  80%    635
  90%    675
  95%    700
  98%    756
  99%    793
 100%   1532 (longest request)


(8.)查看xcache的命中率:


六、部署bbs论坛


(1.)将Discuz的程序文件解压,并且将upload中所有文件放置到网站目录(php服务器的操作)

[root@kang ~]# unzip Discuz_7.2_FULL_SC_UTF8.zip  -d  discus

[root@kang ~]# mv discus/upload/ /var/www/benet/bbs

(2.)设置php-fpm的服务用户为下面文件的属主或者对其设置写权限,否则安装时会报错

[root@kang ~]# cd  /var/www/benet/bbs/
[root@kang bbs]# chown -R nobody config.inc.php attachments/ forumdata/ uc_client/data/cache/ templates/
[root@kang bbs]# chmod -R 777 uc_server/data/


(3.)修改php.ini文件

short_open_tag = On


(4.)重启PHP服务

[root@kang ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
(5.)web服务器也需要有静态文件(apache服务器上操作)

[root@kang ~]# unzip Discuz_7.2_FULL_SC_UTF8.zip  -d  discus
[root@kang ~]# mv discus/upload/ /var/www/benet/bbs

(6.)设置httpd的服务用户对指定文件也需要有写入权限

[root@kang ~]# cd /var/www/benet/bbs/
[root@kang bbs]# chown -R daemon config.inc.php attachments/ forumdata/ uc_client/data/cache/ templates/
[root@kang bbs]# 

(7.)在数据库(MySQL)服务器上创建bbs数据库及授权帐户

mysql> create database bbsdb;
Query OK, 1 row affected (0.49 sec)

mysql> grant all on bbsdb.* to runbbs@'%' identified by 'pwd123';
Query OK, 0 rows affected, 1 warning (0.49 sec)

mysql> 


(8.)配置完成之后,输入httd//192.168.197.167/bbs/install即可安装



填写数据库的相关信息,添加数据库服务器的地址和MariaDB创建的数据库和用户密码,而后在设置bbs的管理员帐号密码就可以继续安装了。

剩下的根据提示安装即可。











注意:

出现上面这种情况是由于php服务器安装了discuz之后导致程序发生变化从而导致动态服务器和静态服务器的程序不一致,只需要手动把bbs服务器(PHP)的文件和web服务器(Apache)进行一次同步即可,如果想实现自动同步,需要使用其他服务,如initory+rsync、sersync等工具。

(9.)同步数据(PHP上操作)

[root@kang ~]# scp -r /var/www/benet/bbs/* root@192.168.197.167:/var/www/benet/bbs/

动态服务器和静态服务器同步文件之后,再次访问bbs的网址就正常了。




总结:

(1.)PHP在lamp环境下的三种工作模式:cgi模式、Apache模块、fscgi模式(PHP工作机制)

(2.)搭建lamp(安装相关依赖包、源码编译安装)

(3.)利用Apache自带的压力测试工具ab,进行网站的压力测试

(4.)搭建xcache工具,专门给PHP进行加速,提高PHP的性能以及运行上的效率。

(5.)搭建bbs论坛,基于lamp平台之上运行(Apache与PHP两台服务器上同时创建自己的网站虚拟根目录用于存放网页)


到这里使用FCGI模式编译安装LAMP平台以及搭建XCAHCE部署BBS论坛,演示完毕!!

希望对你有所帮助!!!再见再见再见






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值