C/C++教程

Centos7.6搭建Lamp环境

本文主要是介绍Centos7.6搭建Lamp环境,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Centos7.6搭建Lamp环境

参考:【四】Centos 7.6 mysql 数据库安装和配置_mrdonghe的博客-CSDN博客_centos7配置数据库

CentOS 7 yum 安装 PHP7.3 教程_laohe08的博客-CSDN博客

centos7 apache无法解析php_Joker_Daddy的博客-CSDN博客_apache不能解析php文件

环境:

Centos7.6

Apache2.4.6

php7.3

mysql

安装Apache

yum install httpd -y
systemctl start httpd

安装mysql

//myql扩展
yum install mysql mysql-devel
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

systemctl start mysqld
systemctl enable mysqld

//首次登陆
mysql -u root
//查看数据库
mysql> show databases;
//修改数据root用户密码
mysql> set password for 'root'@'localhost' =password('password');
//设置远程登录root
mysql> grant all privileges on *.* to root@'%'identified by 'password';

安装PHP7.3

//安装 EPEL 源
yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm  

//安装yum源管理工具
yum install yum-utils

//安装php7.3
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll

systemctl enable php73-php-fpm
systemctl start php73-php-fpm

//编辑/etc/opt/remi/php73/php.ini替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini

//重启php73-php-fpm
systemctl restart php73-php-fpm

//验证php是否安装成功
php73 -v


注意:使用acache输出php文件时候会出现php文件解析不了
可以将以下内容保存在/etc/httpd/conf.modules.d/10-php-fpm.conf
<FilesMatch \.php$>
         SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
这篇关于Centos7.6搭建Lamp环境的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!