码迷,mamicode.com
首页 > 数据库 > 详细

Centos7 配置LAMP(mysql+mariadb+php+phpMyAdmin)

时间:2018-10-10 19:28:01      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:password   tar   login   user   启动服务   setting   创建   clean   none   

安装apache
安装apache
yum install httpd httpd-devel -y

启动apache服务
systemctl start httpd   #启动服务
systemctl status httpd  #查看状态
systemctl enable httpd  #设置开机自动启动服务

查看服务器IP并用浏览器登录页面
ip a
http://192.168.0.64

安装mysql

yum install mariadb mariadb-server mariadb-libs mariadb-devel -y        #安装相关组件
rpm -qa |grep maria #检查安装结果
    [root@localhost ~]# rpm -qa |grep maria
    mariadb-5.5.60-1.el7_5.x86_64
    mariadb-server-5.5.60-1.el7_5.x86_64
    mariadb-libs-5.5.60-1.el7_5.x86_64
    mariadb-devel-5.5.60-1.el7_5.x86_64

systemctl start mariadb     #启动mariadb
systemctl status mariadb    #查看服务状态
systemctl enable mariadb    #设置开机自动启动服务

使用 mysql_secure_installation 初始化数据库安全设置

  • 输入root密码,没有密码直接回车

    [root@localhost ~]# mysql_secure_installation
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we‘ll need the current
    password for the root user.  If you‘ve just installed MariaDB, and
    you haven‘t set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
  • 提示设置root user密码,Y

    Setting the root password ensures that nobody can log into the MariaDB
    root user without the proper authorisation.
    
    Set root password? [Y/n] y
    New password: 
    Re-enter new password: 
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
  • 删除系统创建的默认匿名用户:Y

    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y
     ... Success!
  • 禁止root用户远程登录:Y

    Normally, root should only be allowed to connect from ‘localhost‘.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] y
     ... Success!
  • 是否删除系统创建的test数据库,生产环境建议删除

    By default, MariaDB comes with a database named ‘test‘ that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] n
     ... skipping.
  • 重载权限表:Y

    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y
     ... Success!
  • 完成

    Cleaning up...
    
    All done!  If you‘ve completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!

Install PHP

yum install php php-mysql php-gd php-pear -y    #命令1,两个命令均可。
yum install php* -y     #命令2,两个命令均可。

测试PHP
vi /var/www/html/info.php,并编辑以下内容

    <?php 
        phpinfo();
    ?>

打开http://192.168.0.64/info.php可以看到php版本信息

Install phpMyAdmin(可选)

phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。由于phpMyAdmin跟其他PHP程式一样在网页服务器上执行,您可以在任何地方使用这些程式产生的HTML页面,也就是于远端管理MySQL数据库,方便的建立、修改、删除数据库及资料表。也可借由phpMyAdmin建立常用的php语法,方便编写网页时所需要的sql语法正确性。

添加 EPEL repository   参照(Install EPEL Repository on RHEL/CentOS/Scientific Linux 7)
    yum install epel-release

安装 phpMyAdmin:
    yum install phpmyadmin -y

配置 phpMyAdmin
    phpMyAdmin默认只能由本机访问。为了能够远程访问,编辑phpmyadmin.conf file:
        vi /etc/httpd/conf.d/phpMyAdmin.conf

打开 phpMyAdmin
    http://192.168.0.61/phpMyAdmin

Centos7 配置LAMP(mysql+mariadb+php+phpMyAdmin)

标签:password   tar   login   user   启动服务   setting   创建   clean   none   

原文地址:http://blog.51cto.com/12254228/2298275

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!