阿里云通过yum安装LAMP(成功安装上)centos7.4

https://blog.csdn.net/qiaosym/article/details/78710305

----------------------------------

              一、检查

----------------------------------

1、查看centos版本

[root@iZ2ze1z1rt2rdghjk34rt ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) 

2、查看Apache

httpd -v

3、查看mysql

service mysqld start

4、安装过进行清理

yum remove mysql
rm -f /etc/my.cnf
rpm -qa | grep httpd

----------------------------------

        二、安装apache

----------------------------------

1、安装apache

yum -y install httpd

2、安装apache扩展

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

3、启动apache

systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止
systemctl restart httpd.service #重启

4、设置开机自启动

systemctl enable httpd.service

5、检查安装情况,浏览器访问ip,安装成功,结果如下

----------------------------------

       三、安装php

----------------------------------

1、安装php

yum -y install php

2、安装php-fpm

yum -y install php-fpm

3、安装php扩展

yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel

4、测试php安装(如果内容原样输出出来,请重启apache)

cd /var/www/html

vim v.php #编辑

编写代码( i 键进入编辑模式)

1.<?php
2.    echo '<title>hello world</title>';
3.    phpinfo();
3.?>


esc 回到控制模式, :wq 保存退出. 

浏览器访问域名加路径,运行v.php. 如: 127.0.0.1/v.php 

----------------------------------

       四、安装mysql(mariadb)

----------------------------------

 

1、安装数据库Mariadb它是MySQL的一个分支几乎兼容mysql所有功能,执行下面命令;

yum -y install mariadb-server mariadb

2、启动mariadb并且设置为它开机启动;检查是否启动和开机启动

systemctl start mariadb

systemctl enable mariadb

systemctl status mariadb

systemctl is-enabled mariadb

3、下面配置root密码和数据库的一些安全;执行命令,

mysql_secure_installation

#将会输出让输入原始密码(这里默认为空密码请直接回车Enter),

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): 

#这里询问我们是否设置root密码,输入y设置密码,y(设置);  n(不设置)

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

Set root password? [Y/n] 

#输入密码再次确认密码回车

Set root password? [Y/n] y

New password: 

Re-enter new password: 

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

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  (询问是否移除匿名用户输入y回车)

 ... Success!

  

 

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]  n(询问是否禁止远程root登陆我这里选择y禁止远程登录【如果您需要远程登录连接数据库可选择n】)

 

... skipping.

 

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]  y(询问是否删除测试数据库【可选项随意y或n】这里我选择y)

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n]  y (询问是否现在重新加载权限表选择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!

 

 

#会自动跳到命令页面,到此我们的数据库设置了密码和一些安全。

 


我们可以简单登录下数据库;

mysql -uroot -p

Enter password: 【输入密码回车即可登录进去】

 

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 13

Server version: 5.5.56-MariaDB MariaDB Server

 

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> show databases;            【命令显示数据库列表】

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

4 rows in set (0.01 sec)

 

MariaDB [(none)]> quit                                【退出数据库】

Bye

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值