centos7安装安装apache配置php-fpm

centos7安装安装apache配置php-fpm

安装apache(httpd),使用SCL源

# 安装
yum install httpd24
# 查看服务名称systemctl list-unit-files
httpd24-httpd.service
# 启动,即可访问ip浏览
systemctl start httpd24-httpd.service
# 查看环境配置文件
# 在/opt/rh/httpd24/root/usr/sbin/httpd
# 在/opt/rh/httpd24/root/etc/httpd/run/httpd.pid
ps -aux |grep httpd
# 配置php-fpm查看配置
/opt/rh/httpd24/root/usr/sbin/httpd -t
# httpd: Syntax error on line 56 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf: Syntax error on line 40 of /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-base.conf: Cannot load modules/mod_http2.so into server: libnghttp2-httpd24.so.14: cannot open shared object file: No such file or directory
# 配置文件/opt/rh/httpd24/root/etc/httpd/conf/httpd.conf
# ServerRoot "/opt/rh/httpd24/root/etc/httpd"
# DocumentRoot "/opt/rh/httpd24/root/var/www/html"
# 新建index.php文件
cd /opt/rh/httpd24/root/var/www/html
touch index.php
nano index.php
# 添加
# 配置php-fpm
nano /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf
# php-fpm模块
LoadModule proxy_module /opt/rh/httpd24/root/etc/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module /opt/rh/httpd24/root/etc/httpd/modules/mod_proxy_fcgi.so
# url rewrite模块
LoadModule rewrite_module /opt/rh/httpd24/root/etc/httpd/modules/mod_rewrite.so
# 添加对php页面的支持(可不加)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# 配置文件最后加上,9000是php-fpm端口
# 配置php-fpm,参考https://blog.csdn.net/HD2killers/article/details/82733683

    SetHandler "proxy:fcgi://127.0.0.1:9000"

# 首页默认文件 可以写多个

    DirectoryIndex index.html index.php

# 重启httpd
systemctl restart httpd24-httpd.service

你可能感兴趣的:(php,centos,rh)