基于源码编译FCGI的模式的LAMP的wordpress和discuz的虚拟主机--十二周目
环境 两台主机
ip: 172.22.7.71 mysql server
ip: 172.22.7.70 apachectl,fgci服务器
软件版本:
mariadb-10.2.23-linux-x86_64.tar.gz
apr-1.7.0.tar.gz
apr-util-1.6.1.tar.gz
httpd-2.4.39.tar.bz2
php-7.3.5.tar.bz2
wordpress-5.2.tar.gz
Discuz_X3.3_SC_UTF8.zip
mysql server
编译安装mariadb
1,安装包
yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boostdevel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssldevel libevent-devel libaio-devel -y
2,作准备用户和数据目录
useradd –r –s /sbin/nologin –d /data/mysql/ mysql
mkdir /data/mysql
chown mysql.mysql /data/mysql
tar xvf mariadb-10.2.23-linux-x86_64.tar.gz
3,cmake编译安装
cd mariadb-10.2.23/
cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/data/mysql/ \
-DSYSCONFDIR=/etc/mysql \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
提示:若是出错,执行rm -f CMakeCache.txt
4,准备环境变量
echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
5,生成数据库文件
cd /app/mysql/
scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql
6,准备配置文件
cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
7,准备启动脚本
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
8,启动服务
chkconfig --add mysqld
service mysqld start
建立mysql数据库及连接mysql用户帐号
mysql -e "create database wordpress;"
mysql -e "grant all on wordpress.* to wpuser@'172.22.7.70' identified by 'centos';"
mysql -e "grant all on ultrax.* to discuz@'172.22.7.70' identified by 'centos';"
apachectl,fgci服务器
编译安装httpd
1,环境
centos7.6
apr-1.7.0.tar.gz
apr-util-1.6.1.tar.gz
httpd-2.4.39.tar.bz2
2,安装工具包
yum install gcc pcre-devel openssl-devel expat-devel autoconf libtool gcc-c++ -y
3,解压包及建立数据目录
cd /data
tar xvf apr-1.7.0.tar.gz
tar xvf apr-util-1.6.1.tar.gz
tar xvf httpd-2.4.39.tar.bz2
cp -r apr-1.7.0 httpd-2.4.39/srclib/apr
cp -r apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
4,编译安装
cd httpd-2.4.39/
./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-apr=/app/apr/ \
--with-apr-util=/app/apr-util/ \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
make -j 4 && make install
5,准备环境变量
vim /etc/profile.d/httpd24.sh
PATH=/app/httpd24/bin:$PATH
6,建立系统用户
useradd -r -s /sbin/nologin apache
7,修改配置文件更改httpd用户和组
vim /app/httpd24/conf/httpd.conf
User apache
group apache
8,准备启动脚本
vim /etc/rc.d/rc.local
/app/httpd24/bin/apachectl start
chmod +x /etc/rc.d/rc.lcal
9,启动服务,重启
apachetcl start
reboot
修改配置文件
vim /app/httpd24/conf/httpd.conf
#更改用户,组
user apache
group apache
#取消如下两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
修改如下配置
DirectoryIndex index.php index.html
#末尾添加如下内容
<virtualhost *:80>
documentroot /data/wordpress
servername blog.magedu.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
<directory /data/wordpress>
require all granted
</directory>
</virtualhost>
<virtualhost *:80>
documentroot /data/discuz
servername forum.magedu.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
<directory /data/discuz>
require all granted
</directory>
</virtualhost>
编译安装基于fcgi的php
1,安装工具包
yum install libxml2-devel bzip2-devel libmcrypt-devel (基于EPEL)
2,编译
cd php-7.3.5/
./configure --prefix=/app/php
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-openssl
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir=/usr
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--enable-mbstring
--enable-xml
--enable-sockets
--enable-fpm
--enable-maintainer-zts
--disable-fileinfo
make -j 4 && make install
3,修改配置
cp php.ini-production /etc/php.ini
vim /etc/php.ini
修改时区 (zone)
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cd /app/php/etc/
cp php-fpm.conf.default php-fpm.conf
cd /app/php/etc/php-fpm.d/
cp www.conf.default www.conf
vim www.conf
user = apache
group = apache
;listen = 127.0.0.1:9000(注销)
4,启动服务
service php-fpm start
准备相关的php程序文件
ls /data/wordpress
ls /data/discuz
setfacl -R -m u:apache:rwx /data/discuz/
firefox blog.magedu.com
firefox discuz.magedu.com
完成