当前位置:Gxlcms > 数据库问题 > Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)

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

时间:2021-07-01 10:21:17 帮助过:15人阅读

环境:阿里云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 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/

 

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

标签:mariadb   root   doc   module   over   cgi   ase   post   ima   

人气教程排行