Centos6编译安装LAMP(FPM模块方式)加速的WordPress应用

前端之家收集整理的这篇文章主要介绍了Centos6编译安装LAMP(FPM模块方式)加速的WordPress应用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

准备软件版本:


apr-1.5.2.tar.bz2
apr-util-1.5.4.tar.bz2
httpd-2.4.27.tar.bz2
mariadb-5.5.57-linux-x86_64.tar.gz(二进制)
PHP-5.6.31.tar.bz2
xcache-3.2.0.tar.gz
wordpress-4.8-zh_CN.tar.gz

一. 源码编译安装 httpd2.4



1.准备编译环境安装

yumgroupinstall"developmenttools"-y
yuminstallopenssl-develexpat-develpcre-devel-y

2.准备安装包及文件

tarxfapr-1.5.2.tar.bz2
tarxfapr-util-1.5.4.tar.bz2
tarxvfhttpd-2.4.27.tar.bz2
cp-rapr-1.5.2httpd-2.4.27/srclib/apr
cp-rapr-util-1.5.4httpd-2.4.27/srclib/apr-util
cdhttpd-2.4.27/

3.开始编译安装

./configure--prefix=/app/httpd24\
--sysconfdir=/etc/httpd24\
--enable-so\
--enable-ssl\
--enable-rewrite\
--with-zlib\
--with-pcre\
--with-included-apr\
--enable-modules=most\
--enable-mpms-shared=all\
--with-mpm=prefork

make-j4&&makeinstall

4.配置httpd管理命令路径

vim/etc/profile.d/lamp.sh
PATH=/app/httpd24/bin/:$PATH
./etc/profile.d/lamp.sh

5.配置服务脚本并启动

cp/etc/init.d/httpd/etc/init.d/httpd24#如没有httpd可从其他主机拷贝过来

vim/etc/init.d/httpd24#修改配置文件
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

chkconfig--addhttpd24
chkconfig--listhttpd24
servicehttpd24start

二. 二进制安装及配置 mariadb



1.二进制安装mariadb

yumremoveMysqL-y#centos6默认安装MysqL并创建了用户名,安装较新版mariadb避免冲突要卸载MysqL
tarxvfmariadb-5.5.57-linux-x86_64.tar.gz-C/usr/local
cd/usr/local
ln-smariadb-5.5.57-linux-x86_64/MysqL
chown-Rroot:MysqLMysqL/
cdMysqL/
scripts/MysqL_install_db--datadir=/app/MysqLdb--user=MysqL#创建数据库文件

2.配置 mariadb 配置文件

mkdir/etc/MysqL
cpsupport-files/my-large.cnf/etc/MysqL/my.cnf
vim/etc/MysqL/my.cnf#在[MysqLd]下添加如下三条配置
[MysqLd]
datadir=/app/MysqLdb
innodb_file_per_table=ON
skip_name_resolve=ON

3.配置服务脚本并启动

cpsupport-files/MysqL.server/etc/init.d/MysqLd
chkconfig--addMysqLd
chkconfig--list

4.配置日志文件

touch/var/log/MysqLd.log
chownMysqL/var/log/MysqLd.log
serviceMysqLdstart

5.配置命令路径

vi/etc/profile.d/lamp.sh
PATH=/usr/local/MysqL/bin/:/app/http24/bin:$PATH
./etc/profile.d/lamp.sh

6.安全初始化及创建用户数据库文件

MysqL_secure_installation

MysqL-uroot-pcentos
createdatabasewpdb;
grantallonwpdb.*towpuser@'%'identifiedby'centos';

三.编译安装 PHP 及配置



1.编译前准备

yuminstalllibxml2-develbzip2-devellibmcrypt-devel(在epepl源)
tarxvfPHP-5.6.31.tar.xz
cdPHP-5.6.31

2.开始编译

./configure\
--prefix=/app/PHP5\
--with-MysqL=/usr/local/MysqL\
--with-openssl\
--with-MysqLi=/usr/local/MysqL/bin/MysqL_config\
--enable-mbstring\
--with-freetype-dir\
--with-jpeg-dir\
--with-png-dir\
--with-zlib\
--with-libxml-dir=/usr\
--enable-xml\
--enable-sockets\
--enable-fpm\
--with-mcrypt\
--with-config-file-path=/etc/PHP5\
--with-config-file-scan-dir=/etc/PHP5.d\
--with-bz2

make-j4&&makeinstall

3.配置命令路径

vi/etc/profile.d/lamp.sh
PATH=/app/PHP5/bin:/app/httpd24/bin/:/usr/local/MysqL/bin/:$PATH
./etc/profile.d/lamp.sh

4.准备配置文件及服务脚本文件

mkdir/etc/PHP5/
cpPHP.ini-production/etc/PHP5/PHP.ini

cpsapi/fpm/init.d.PHP-fpm/etc/init.d/PHP-fpm
chmod+x/etc/init.d/PHP-fpm
chkconfig--addPHP-fpm
chkconfig--listPHP-fpm

cd/app/PHP5/etc
cpPHP-fpm.conf.defaultPHP-fpm.conf

5.编辑httpd相关配置参数

vim/etc/httpd24/httpd.conf
#取消两行的注释
LoadModuleproxy_modulemodules/mod_proxy.so
LoadModuleproxy_fcgi_modulemodules/mod_proxy_fcgi.so
#在文件尾部加四行
AddTypeapplication/x-httpd-PHP.PHP
AddTypeapplication/x-httpd-PHP-source.PHPs
ProxyRequestsOff#关闭正向代理
ProxyPassMatch^/(.*\.PHP)$fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
#修改下面行
<IfModuledir_module>
DirectoryIndexindex.PHPindex.html
</IfModule>

servicehttpd24restart

6.编辑主页文件测试数据库是否连接

vim/app/httpd24/htdocs/index.PHP
<html><body><h1>Itworks!</h1></body></html>
<?PHP
$MysqLi=newMysqLi("localhost","root","centos");
if(MysqLi_connect_errno()){
echo"连接数据库失败!";
$MysqLi=null;
exit;
}
echo"连接数据库成功!";
$MysqLi->close();


$conn=MysqL_connect('localhost','root','centos');
if($conn)
echo"OK";
else
echo"Failure";
MysqL_close();

PHPinfo();

?>

四. 配置wordpress



1.安装

tarxvfwordpress-4.8.1-zh_CN.tar.gz-C/app/httpd24/htdocs
cd/app/httpd24/htdocs
mvwordpress/blog/

cd/app/httpd24/htdocs/blog/
cpwp-config-sample.PHPwp-config.php

2.编辑配置文件

vimwp-config.php
define('DB_NAME','wpdb');

/**MysqL数据库用户名*/
define('DB_USER','wpuser');

/**MysqL数据库密码*/
define('DB_PASSWORD','centos');

/**MysqL主机*/
define('DB_HOST','localhost');

3.登录主机测试

http://websrv/blog#配置用户信息
测试性能
ab-c10-n100http://websrv/blog/

五.编译xcache 实现PHP加速


1.编译安装准备

tarxvfxcache-3.2.0.tar.bz2
cdxcache-3.2.0

PHPize#生成configure文件

2.编译安装

./configure--enable-xcache--with-PHP-config=/app/PHP/bin/PHP-config
make&&makeinstall

3.编辑配置文件

mkdir/etc/PHP.d/
cpxcache.ini/etc/PHP.d/
vim/etc/PHP.d/xcache.ini
extension=/app/PHP/lib/PHP/extensions/no-debug-non-zts-20131226/xcache.so
servicePHP-fpmrestart

4.测试性能

ab-c10-n100http://websrv/blog/
原文链接:https://www.f2er.com/centos/375610.html

猜你在找的CentOS相关文章