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   


DirectoryIndex index.php index.html

4.重启服务并验证

# systemctl restart httpd 

#echo ""  > /var/www/html/index.php

浏览器访问IP

Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)_第1张图片

 #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


ServerName svr1.tecadmin.net
ServerAdmin [email protected]
DocumentRoot /var/www/html
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

Options +Indexes +FollowSymLinks +ExecCGI
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/php.fastcgi
AllowOverride All
Order allow,deny
Allow from All

重启服务

# systemctl restart httpd 

再次登录访问http://IP

Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)_第2张图片

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

 

转载于:https://www.cnblogs.com/gaoyuanzhi/p/8039357.html

你可能感兴趣的:(Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd))