I'm the gatekeeper of my own destiny

导航

虚拟机中CentOS 7下PHP环境配置

      为了简单起见,虚拟机网卡设置为桥接模式

       1.yum install  httpd php

       2.yum install mariadb

       3.启动mariadb        

systemctl start mariadb.service #启动MariaDB

systemctl stop mariadb.service #停止MariaDB

systemctl restart mariadb.service #重启MariaDB

systemctl enable mariadb.service #设置开机启动

创建一个新用户用来远程访问

mysql -u root -p    进入数据库
user mysql; #使用mysql系统数据库

insert into user(Host,User,Password) values('%','test',PASSWORD('123')); 
#插入一个名为test的新用帐号为test,密码为123,可根据自身需要自行修改

Update user set Password=PASSWORD('123') where User='root'
#将root密码改为123,作为重置root密码之用

select * from user; #查看用户是否加入

grant all privileges on *.* to test@'%' identified by '123';     test为账号,%为主机地址,目前代表所有 123代表密码

flush privileges;  刷新

select user,host from user; #查看用户是否加入

 

       4.关闭防火墙为是了让主机可以访问虚拟机中网站       

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

5.主机打开虚拟机IP即可访问

6.测试PHP

cd /var/www/html

vi index.php #输入下面内容

<?php

phpinfo();

?>

:wq! #保存退出

在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!

 

 

注意:apache默认的程序目录是/var/www/html

权限设置:chown apache.apache -R /var/www/html

至此,CentOS 7.0安装配置LAMP服务器(Apache+PHP+MariaDB)教程完成!

 
 

 


 
 

 

 

posted on 2016-03-04 23:09  Wishbay  阅读(1498)  评论(0编辑  收藏  举报