Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)相关的知识,希望对你有一定的参考价值。

环境:阿里云centos7.3

一、安装并配置数据库

1.安装数据库

#yum install mariadb-server  mariadb -y

2.启动服务并设置开机自启

# systemctl start mariadb && systemctl enable mariadb && systemctl status mariadb

3.初始化数据库

 # mysql_secure_installation 

二、安装php7.0

1.配置源

#yum install -y epel-release

#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2.安装php7

#yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 -y

3.配置php-fpm源

#rpm -Uvh   http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

4.安装php-fpm

#yum install -y php70-php-fpm.x86_64

三、安装并配置httpd

1.安装httpd

#yum install httpd -y

2.启动服务并设置开机自启

#systemctl start httpd && systemctl enable httpd  && systemctl status httpd

3.编辑配置文件,使httpd支持PHP

 vi /etc/httpd/conf/httpd.conf   

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

4.重启服务并验证

# systemctl restart httpd 

#echo "<?php phpinfo();?>"  > /var/www/html/index.php

浏览器访问IP

技术分享图片

 #vi /var/www/cgi-bin/php.fastcgi

#!/bin/bash

PHPRC="/etc/php.ini"
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi

#chown apache:apache /var/www/cgi-bin/php.fastcgi
#chmod +x /var/www/cgi-bin/php.fastcgi

#vi /etc/httpd/conf.d/fastcgi.conf

<VirtualHost *:80>
ServerName svr1.tecadmin.net
ServerAdmin [email protected]
DocumentRoot /var/www/html
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/html">
Options +Indexes +FollowSymLinks +ExecCGI
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/php.fastcgi
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

重启服务

# systemctl restart httpd 

再次登录访问http://IP

技术分享图片

参考: https://tecadmin.net/setup-httpd-with-fastcgi-and-php-on-centos-redhat/

 























以上是关于Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)的主要内容,如果未能解决你的问题,请参考以下文章

LAMP- CentOS 7平台三机FastCGI模型

实战案例:编译安装基于 FastCGI 模式LAMP架构多虚拟主机WEB应用(WordPress 和Discuz)

企业LAMP+gd + fretds + fastcgi + memcache环境安装配置

生产环境LAMP搭建 - 基于 fastcgi

编译安装LAMP之配置httpd以FastCGI方式与php整合

LAMP 之 自动化编译安装