基于UDS模式的php-fpm的LAMP

环境

linux、apache、php-fpm linux、mariadb linux client
192.168.43.17 192.168.43.7 192.168.43.6
apache_php-fpm mariadb ab工具测试

配置 httpd 服务器

编译安装 httpd-2.4.41

创建用户
[apache_php-fpm]#

useradd -r -s /sbin/login apache

配置文件
[apache_php-fpm]#

mkdir /app/httpd24/conf.d/
echo "IncludeOptional conf.d/*.conf" >> /app/httpd24/conf/httpd.conf
cat <<EOF > /app/httpd24/conf.d/httpd_php.conf
User apache
Group apache
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
AddType application/x-httpd-source .phps
proxyrequests off
ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php5-fpm.sock|fcgi://localhost/app/httpd24/htdocs/"
EOF

httpd服务的启动脚本
[apache_php-fpm]#

vim /usr/lib/systemd/system/httpd24.service
[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
#EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/app/httpd24/bin/httpd $OPTIONS -k start
ExecReload=/app/httpd24/bin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

安装相关软件
[apache_php-fpm]#

yum install php-fpm php-mysql -y

配置php-fpm

[apache_php-fpm]#

cat <<EOF > /etc/php-fpm.d/optimization.conf
pm.start_servers = 30
pm.min_spare_servers = 20
pm.max_spare_servers = 60
pm.max_children = 500
pm = dynamic
pm.max_requests = 500
pm.status_path = /status
ping.path = /ping
ping.response = pong
EOF
cat <<EOF > /etc/php-fpm.d/httpd_php.conf
listen.owner = apache
listen.group = apache
listen = /var/run/php5-fpm.sock
listen.mode = 0666
EOF

启动服务

[apache_php-fpm]#

systemctl start httpd24
systemctl start php-fpm

安装 mariadb,配置授权

[mariadb]#

yum install mariadb-server -y
systemctl start mariadb
mysql -e "create database discuz;grant all on discuz.* to discuz@'192.168.43.%'  identified by 'discuz';flush privileges;"

将 discuz 程序挂载到网站的根目录

[apache_php-fpm]#

cd /app/httpd24/htdocs/
unzip Discuz_X3.2_SC_UTF8.zip
ls
Discuz_X3.2_SC_UTF8.zip  index.html  readme  upload  utility
mv upload/ forum
setfacl -Rm u:apache:rwx forum/

windows中的浏览器访问

http://192.168.43.17/forum/install/
在这里插入图片描述
在这里插入图片描述

linux客户端访问

[client]#

ab -c1000 -n 1000 http://192.168.43.17/forum/

基于端口httpd支持php-fpm的配置

vim /etc/httpd/conf.d/fcgi.conf
directoryindex index.php
proxyrequests off
proxypassmatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1

官方文档

Apache Module mod_proxy_fcgi

发布了61 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/studywinwin/article/details/104136709