新建逻辑卷挂载至数据目录;
# pvcreate /dev/sdb
# vgcreate -s 8M data /dev/sdb
# lvcreate -L 49G -n mydata data
# mke2fs -text4 –b 4096 /dev/data/mydata
# mkdir /data
# vim /etc/fstab
> /dev/data/mydata /data ext4 defaults 0 0
# mount –a
# mkdir -p /data/mydata
# groupadd -r mysql
# useradd -g mysql -r mysql
# chown -R mysql:mysql /data/mydata/
# chmod -R o-rx /data/mydata/
二进制安装设置;
# tar xf mariadb-5.5.44-linux-x86_64.tar.gz -C /usr/local/
# cd /usr/local/
# ln -sv mariadb-5.5.44-linux-x86_64 /mysql
# cd mysql/
# chown -R root:mysql ./*
# scripts/mysql_install_db --user=mysql --datadir=/data/mydata/
添加,并重读环境变量:
# vim /etc/profile.d/mysql.sh
> export PATH=/usr/local/mysql/bin:$PATH
# source /etc/profile.d/mysql.sh
导出头文件;
# ln -sv /usr/local/mysql/include/ /usr/include/mysql
导出,并重读库文件;
# vim /etc/ld.so.conf.d/mysql.conf
> /usr/local/mysql/lib
# ldconfig
导出man手册;
# vim /etc/man.config
> MANPATH /usr/local/mysql/man
提供配置文件;
# mkdir -p /etc/mysql
# cp support-files/my-small.cnf /etc/mysql/my.cnf
# vim /etc/mysql/my.cnf
> [mysqld]
> thread_concurrency = 2 :值CPU个数乘以2;
> datadir = /data/mydata :数据目录;
提供服务脚本,并添加执行权限:
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld
启动,初始化数据库;
# chkconfig mysqld –add
# chkconfig mysqld on
# service mysqld start
# ss -tnl | grep :3306
# ll /data/mydata/
至此LAMP平台部署完成,接下来为PHP-fpm服务器部署xcache实现加速;
xcache:快速而且稳定的PHP opcode缓存,经过严格测试且被大量用于生产环境。
编译安装xcache:
xcache源码包:xcache-3.1.2.tar.bz2
官网:
xcache:
# tar xf xcache-3.1.2.tar.bz2
# cd xcache-3.1.2
# /usr/local/php/bin/phpize :生成configure脚本;
# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
# make && make install
配置xcache:
# mkdir -p /etc/php.d
# cp xcache.ini /etc/php.d/
# vim /etc/php.d/xcache.ini
> extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
重启PHP-fpm服务:
# service php-fpm restart
xcache已安装完成,接下来进行站点配置;
站点配置:
phpMyAdmin:phpMyAdmin-4.3.13.1-all-languages.tar.bz2
wordpress:wordpress-4.2.2-zh_CN.tar.gz
官网:
Web服务器配置:
# vim /etc/httpd/httpd.conf
> #DocumentRoot"/usr/local/apache/htdocs" :关闭中心主机;
> Include/etc/httpd/extra/httpd-vhosts.conf :启用虚拟主机;
启用模块:
> LoadModule proxy_modulemodules/mod_proxy.so :启用反向代理模块;
> LoadModuleproxy_fcgi_module modules/mod_proxy_fcgi.so :启用实现FastCGI模块,此模块为mod_proxy.so的扩充;
支持PHP:
> <IfModuledir_module>
> DirectoryIndex index.php index.html
> </IfModule>
> AddTypeapplication/x-httpd-php .php
> AddTypeapplication/x-httpd-php-source .phps
配置虚拟主机:
# vim /etc/httpd/extra/httpd-vhosts.conf
> <VirtualHost192.168.1.10:80>
> DocumentRoot "/web/pma"
> ServerName pma.chencer.org
> ProxyRequests Off :关闭正向代理;
> ProxyPassMatch ^/(.*\.php)$fcgi://192.168.1.11:9000/web/pma/$1 :代理至PHP-fpm服务器;
> <Directory "/web/pma">
> Options none
> AllowOverride none
> Require all granted
> </Directory>
> </VirtualHost>
>
> <VirtualHost192.168.1.10:80>
> DocumentRoot "/web/blog"
> ServerName blog.chencer.org
> ProxyRequests Off
> ProxyPassMatch ^/(.*\.php)$fcgi://192.168.1.11:9000/web/blog/$1
> <Directory "/web/blog">
> Options none
> AllowOverride none
> Require all granted
> </Directory>
> </VirtualHost>