環境:阿里雲centos7.3php
1、安裝並配置數據庫
1.安裝數據庫html
#yum install mariadb-server mariadb -ymysql
2.啓動服務並設置開機自啓web
# systemctl start mariadb && systemctl enable mariadb && systemctl status mariadbsql
3.初始化數據庫數據庫
# mysql_secure_installation apache
2、安裝PHP7.0
1.配置源centos
#yum install -y epel-release瀏覽器
#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmbash
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
3、安裝並配置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 admin@tecadmin.net
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/