LAMP 环境部署的总结方式

1.首先查看linux 环境的防火墙是否关闭

 systemctl status firewalld 
  • 如果防火墙的状态参数是inactive,则防火墙为关闭状态。
  • 如果防火墙的状态参数是active,则防火墙为开启状态。本示例中防火墙为开启状态,因此需要关闭防火墙。

        1.1 关闭防火墙

systemctl disable firewalld

2.关闭SELinux。

        vi /etc/selinux/config 

                编辑最下面 SELINUX 修改为 disabled  之后按  括号里面的(  :wq!  )  保存退出

3 安装apache

yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql

         3.1 运行httpd -v命令可查看Apache的版本号

        3.2 依次运行以下命令启动Apache服务并设置服务开机自启动

                

systemctl start httpd
systemctl enable httpd

在本地机器的浏览器地址栏中,输入http://实例公网IP  出现下图说明配置成功

httpd

 4.安装并配置MySQL

        运行以下命令更新YUM源

rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

运行以下命令安装MySQL。

yum -y install mysql-community-server

运行以下命令查看MySQL版本号

mysql -V

运行以下命令启动MySQL

systemctl start mysqld

运行以下命令设置开机启动MySQL。

systemctl enable mysqld
systemctl daemon-reload

运行以下命令查看MySQL的初始密码。 执行下面语句后 密码一半都是最后的值

grep "password" /var/log/mysqld.log

 首先需要根据上面获取到的默认密码登录到mysql 执行下面的语句 或者

这里可以获取到默认的密码也可以直接修改直接输入

update user  set  password=password( "自己设置的密码" ) where user= 'root' ;

或者直接可以使用下面的语句配置mysql的安全性(推荐上面) 就无需管下面 

mysql_secure_installation

下面这条语句会出现的信息 知识告知

重置root账号的密码

Enter password for user root: #输入上一步获取的root用户初始密码
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration of the plugin.
Using existing password for root.
Estimated strength of the password: 100 
Change the password for root ? (Press y|Y for Yes, any other key for No) : Y #是否更改root用户密码,输入Y
New password: #输入新密码,长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/
Re-enter new password: #再次输入新密码
Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

输入Y删除匿名用户账号。

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : Y  #是否删除匿名用户,输入Y
Success.

输入Y禁止root账号远程登录。

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入Y
Success.

输入Y删除test库以及对test库的访问权限。

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y
- Dropping test database...
Success.

输入Y重新加载授权表。

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加载授权表,输入Y
Success.
All done!

5安装PHP

更新YUM源。

        运行以下命令添加epel源

yum install -y \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

运行以下命令添加Webtatic源。

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

运行以下命令安装PHP。

yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64  php70w-pdo.x86_64   php70w-mysqlnd  php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

运行以下命令查看PHP版本。

php -v

返回结果如下所示,表示安装成功。

运行以下命令,在Apache网站根目录创建测试文件。

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

运行以下命令重启Apache服务。

systemctl restart httpd

在本地机器的浏览器地址栏中,输入http://实例公网IP/phpinfo.php并按Enter键。

显示页面表示安装成功。

6.安装phpMyAdmin

phpMyAdmin是一个MySQL数据库管理工具,通过Web接口管理数据库方便快捷。

运行以下命令准备phpMyAdmin数据存放目录。

mkdir -p /var/www/html/phpmyadmin

下载phpMyAdmin压缩包

cd
wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip

解压phpMyAdmin压缩包

yum install -y unzip
unzip phpMyAdmin-4.0.10.20-all-languages.zip

运行以下命令复制phpMyAdmin文件到准备好的数据存放目录。

mv phpMyAdmin-4.0.10.20-all-languages/*  /var/www/html/phpmyadmin

在本地机器浏览器地址栏,输入http://实例公网 IP/phpmyadmin并按Enter键,访问phpMyAdmin登录页面  之后就是登录 root + 密码进行操作

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值