编译安装基于fastcgi模式的多虚拟主机的wordpress和discuz的LAMP架构
环境准备:
IP 服务器及操作系统 描述 10.0.0.7 CentOS-7.9 httpd+php(fastcgi模式) 10.0.0.17 MariaDB-10.4.22(通用二进制格式) mariadb 服务器
软件版本:
apr-1.7.0.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.46.tar.bz2 php-7.4.28.tar.gz wordpress-5.4.1-zh_CN.tar.gz Discuz_X3.4_SC_UTF8_20210630.zip
实现步骤
1、为wordprss和discuz应用准备数据库和用户帐号
[ root@centos7 ~]
skip_name_resolve = ON
[ root@centos7 ~]
MariaDB [ mysql] > create database wordpress;
MariaDB [ mysql] > create database discuz;
MariaDB [ mysql] > grant all on wordpress.* to wordpress@'10.0.0.%' identified by "wppass" ;
MariaDB [ mysql] > grant all on discuz.* to discuz@'10.0.0.%' identified by 'dispass' ;
MariaDB [ mysql] > FLUSH PRIVILEGES;
2、编译安装 httpd 2.4
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 httpd-2.4.46]
> --prefix= /apps/httpd \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-included-apr \
> --enable-modules= most \
> --enable-mpms-shared= all \
> --with-mpm= event
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
PATH= /apps/httpd/bin:$PATH
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
User apache
Group apache
[ root@centos7 httpd-2.4.46]
LoadModule mpm_event_module modules/mod_mpm_event.so
[ root@centos7 httpd-2.4.46]
mpm_event_module ( shared)
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
[ Unit]
Description= The Apache HTTP Server
After= network.target remote-fs.target nss-lookup.target
Documentation= man:httpd( 8)
Documentation= man:apachectl( 8)
[ Service]
Type= forking
ExecStart= /apps/httpd/bin/apachectl start
ExecReload= /apps/httpd/bin/apachectl graceful
ExecStop= /apps/httpd/bin/apachectl stop
KillSignal= SIGCONT
PrivateTmp= true
[ Install]
WantedBy= multi-user.target
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
3、编译安装 fastcgi 方式的 php 7.4
[ root@centos7 httpd-2.4.46]
[ root@centos7 httpd-2.4.46]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 php-7.4.28]
> --prefix= /apps/php \
> --enable-mysqlnd \
> --with-mysqli= mysqlnd \
> --with-pdo-mysql= mysqlnd \
> --with-openssl \
> --with-zlib \
> --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
[ root@centos7 php-7.4.28]
[ root@centos7 php-7.4.28]
PATH= /apps/php/bin:/apps/httpd/bin:$PATH
[ root@centos7 php-7.4.28]
[ root@centos7 php-7.4.28]
PHP 7.4.28 ( cli) ( built: Mar 12 2022 14:55:19) ( ZTS )
Copyright ( c) The PHP Group
Zend Engine v3.4.0, Copyright ( c) Zend Technologies
[ root@centos7 php-7.4.28]
[ root@centos7 php-7.4.28]
[ root@centos7 php-7.4.28]
[ root@centos7 etc]
[ root@centos7 etc]
[ root@centos7 php-fpm.d]
[ root@centos7 php-fpm.d]
/apps/php/etc/php-fpm.d
[ root@centos7 php-fpm.d]
user = apache
group = apache
pm.status_path = /fpm_status
ping.path = /ping
[ root@centos7 php-fpm.d]
[ opcache]
zend_extension= opcache.so
opcache.enable= 1
[ root@centos7 php-fpm.d]
[ root@centos7 php-fpm.d]
4、修改配置 httpd 支持 php-fpm
[ root@centos7 php-7.4.28]
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
< IfModule dir_module>
DirectoryIndex index.php index.html
< /IfModule>
AddType application/x-httpd-php .php
ProxyRequests Off
< virtualhost *:80>
servername blog.linux2022.com
documentroot /data/blog
< directory /data/blog>
require all granted
< /directory>
ProxyPassMatch ^/( .*\.php) $ fcgi://127.0.0.1:9000/data/blog/$1
ProxyPassMatch ^/( fpm_status| ping) $ fcgi://127.0.0.1:9000/$1
CustomLog "logs/access_blog_log" common
< /virtualhost>
< virtualhost *:80>
servername forum.linux2022.com
documentroot /data/forum
< directory /data/forum/>
require all granted
< /directory>
ProxyPassMatch ^/( .*\.php) $ fcgi://127.0.0.1:9000/data/forum/$1
CustomLog "logs/access_forum_log" common
< /virtualhost>
[ root@centos7 php-7.4.28]
5、准备wordpress和discuz 相关文件
[ root@centos7 php-fpm.d]
[ root@centos7 data]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 ~]
[ root@centos7 opt]
[ root@centos7 opt]
[ root@centos7 opt]
6、测试访问
[ root@centos7 ~]
10.0.0.7 blog.linux2022.com forum.linux2022.com