zoukankan      html  css  js  c++  java
  • 虚拟机中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)教程完成!

     
     

     
     

     

     
  • 相关阅读:
    ioS开发之CoreLocation(GPS定位)
    iOSiOS开发之退出功能(易错)
    iOS开发之判断横竖屏切换
    iOS开发之左右抖动效果
    iOS开发之UIPopoverController
    thinkphp or查询
    Invalid left-hand side in assignment
    实现input表单从右向左输入
    thinkPhp不为空查询
    array_filter()用法
  • 原文地址:https://www.cnblogs.com/wishbay/p/5243780.html
Copyright © 2011-2022 走看看