基於源碼編譯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
完成