第一步:安装必要的httpd服务的rpm包
yum install openssl-devel expat-devel pcre-devel development tools
第二步:源码编译httpd包
cp -r apr-1.6.2 httpd-2.4.28/srclib/apr
cp -r apr-util-1.6.0 httpd-2.4.28/srclib/apr-util
cd httpd-2.4.28/
./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make -j 2 && make install
vim /etc/profile.d/lamp.sh
. /etc/profile.d/lamp.sh
第三步:源码安装mariadb
tar xvf mariadb-10.2.9-linux-x86_64.tar.gz -C /usr/local/
echo '- - - '> /sys/class/scsi_host/host2/scan
pvcreate /dev/sdb
vgcreate vg_mysqldb /dev/sdb
lvcreate -n lv_mysqldb -l +100%FREE vg_mysqldb
mkfs.ext4 /dev/vg_mysqldb/lv_mysqldb
mkfs.ext4 /dev/vg_mysqldb/lv_mysqldb -L data/mysqldb ----挂载卷标
mkdir /data/mysqldb -p ---创建挂载的卷标目录,数据库存放目录
vim /etc/fstab
/dev/vg_mysqldb/lv_mysqldb /data/mysqldb ext4 defaults 0 0
tune2fs -o acl /dev/vg_mysqldb/lv_mysqldb
tune2fs -l /dev/vg_mysqldb/lv_mysqldb
mkdir /etc/mysql/ ---准备配置文件
cp support-files/my-huge.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[mysqld]
datadir = /data/mysqldb
innodb_file_per_table = on这个是每张表都单独存放,互相不影响,方便查看,可以不写
skip_name_resolve = on这个是把名字的反向解析关闭,运行速度会快一点,也可以不写。
scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb ---创建本地数据库
cp support-files/mysql.server /etc/init.d/mysqld ---做成服务脚本
chkconfig --list mysqld
chkconfig --add mysqld
chkconfig --list mysqld
service mysqld start
vi /etc/profile.d/mysql.sh ---加上path变量
PATH=/usr/local/mysql/bin:$PATH
mkdir /var/log/mariadb/ ----创建日志文件
chown mysql /var/log/mariadb/
service mysqld start
mysql_secure_installation ---运行安全脚本
create database blogdb; 创建管理数据库1
grant all on blogdb.* to wpuser@'172.17.252.%' identified by 'centos'; ----授权
grant all on blogdb.* to wpuser@'localhost' identified by 'centos';
create database blogdb2; 创建管理数据库2
grant all on blogdb2.* to wpuser2@'localhost' identified by 'centos'; ---授权
第四步:安装php
yum install bzip2-devel libxm12-devel libmcrypt-devel ---准备必要rpm包 ,可以单独装避免出错
tar xvf php-7.1.10.tar.xz
cd php-7.1.10/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --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 --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
make -j 2 && make install
cp php.ini-production /etc/php.ini ---复制模板文件做成服务脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cd /app/php/etc/ ---准备配置文件
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
service php-fpm start
第五步:准备虚拟主机的配置
/app/httpd24/conf/httpd.conf
AddType application/x-http-php. php添加上
AddType application/x-httpd-php-source .phps 添加上
LoadModule proxy_module modules/mod_proxy.so 注释去掉
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so注释去掉
DirectoryIndex index.php index.html 测试页面
Include conf/extra/httpd-vhosts.conf 去掉注释虚拟主机
vim /app/httpd24/conf/extra/httpd-vhosts.conf --单独配置多站点虚拟主机
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/app/httpd24/htdocs"
ServerName www.a.com
ErrorLog "logs/a.com-error_log"
CustomLog "logs/a.com-access_log" common
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
require all granted
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/app/httpd24/htdocs2"
ServerName www.b.com
ErrorLog "logs/b.com-error_log"
CustomLog "logs/b.com-access_log" common
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs2/$1
require all granted
第六步:配置wordpress ,最好都是单独解压复制,到各自的站点,不然数据库只要登陆就会保存数据,如果数据库出问题,直接把数据库删除,然后重建账号数据库
站点一: tar xvf wordpress-4.8.1-zh_CN.tar.gz --解压
mv wordpress/* /app/httpd24/htdocs/ --不建立文件夹,直接复制到根
cp wp-config-sample.php wp-config.php
cd /app/httpd24/htdocs
vim wp-config.php
define('DB_NAME', 'blogdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'centos');
/** MySQL主机 */
define('DB_HOST', 'localhost');
站点二:
tar xvf wordpress-4.8.1-zh_CN.tar.gz --解压
mv wordpress/* /app/httpd24/htdocs2/ --不建立文件夹,直接复制到根
cp wp-config-sample.php wp-config.php
cd /app/httpd24/htdocs2
vim wp-config.php
define('DB_NAME', 'blogdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'centos');
/** MySQL主机 */
define('DB_HOST', 'localhost');