centos7 php配置mysql数据库_Centos7 配置LAMP(mysql+mariadb+php+phpMyAdmin)

安装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,并编辑以下内容

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值