centos7 下yum安装lamp环境

本来是用的lamp的集成包,但是安装后总是安装失败,索性就直接自己配置一步步搭建好了。

centos7以及网络配置前篇文章已经介绍了,此处直接安装lamp.

一、安装Apache

1、yum 安装

[root@bogon ~]# yum install httpd httpd-devel

2、启动Apache

[root@bogon ~]# systemctl start httpd

3、设置Apache服务开机启动

[root@bogon ~]# systemctl enable httpd

4、测试Apache服务是否开启成功

在浏览器输入IP地址查看(如果不知道ip地址可用ifconfig或者ip addr 查看ip地址),虚拟机有的是否不一定能访问成功,查看很多资料说是需要防火墙开启80端口

[root@bogon ~]# firewall-cmd --premanent --zone=public --add-service=http
[root@bogon ~]# firewall-cmd --permanent --zone=public --add-service=https
[root@bogon ~]# firewall-cmd --reload

以上三步每一步都显示success,再次浏览器访问显示如下图,则说明Apache开启成功

二、安装PHP

1、安装

[root@bogon ~]# yum -y install php

2、重启Apache服务

[root@bogon ~]# systemctl restart httpd

3、测试是否安装成功

[root@bogon ~]# vi /var/www/html/info.php

info文件里可以写段<?php  echo phpinfo();  ?>然后在浏览器打开,如果显示如下页面表示PHP安装成功

三、安装MySQL

1、安装

[root@bogon ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel

2、查看已经安装的Maria包

[root@bogon ~]# rpm -qa |grep maria
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-devel-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64

3、开启MySQL并设置开机启动

[root@bogon ~]# systemctl start  mariadb
[root@bogon ~]# systemctl enable  mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

4、设置root账户密码

[root@bogon ~]# 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...

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!


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!

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
 ... 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
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

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!

5、测试是否安装成功

[root@bogon ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, 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 |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> exit;
Bye

四,将MySQL与PHP关联

[root@bogon ~]# yum install php-mysql

五、安装PHP常用模块

[root@bogon ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath

六、重启Apache服务

[root@bogon ~]# systemctl restart httpd.service

七、再次在浏览器查看安装的模块,就能查看相关内容。

以上就是lamp的安装过程了

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值