美文网首页从代码的世界路过
阿里云ECS上手动部署LAMP

阿里云ECS上手动部署LAMP

作者: ainiok | 来源:发表于2017-07-26 11:33 被阅读13次

    手动部署###

    系统平台:CentOS 7.3
    Apache版本:2.4
    Mysql版本:5.7
    PHP版本:7.0

    一、更新系统###

      使用putty进入ECS后,首先执行yum update命令更新自己的系统
      centos7 中用firewalld 代替了原来的iptables服务,这是根据自己的喜好,我是关闭firewalld使用iptables。
    

    关闭firewall

    1.systemctl stop firewalld.service 
    

    关闭防火墙开机自启

    1.systemctl disable firewalld.service
    

    安装iptables防火墙

     yum install iptables-services
    
    vi /etc/sysconfig/iptables  #编辑防火墙的配置
    

    增加这两行代码

    防火墙配置

    重启防火墙和设置防火墙开机自启

    systemctl restart iptables.service
    systemctl enable iptables.service
    

    安装vim及unzip

    1. yum install -y vim unzip
    

    编译安装apache准备
    编译安装apache 前需要安装apr、apr-util 和pcre 软件包和相关依赖包

    1.  yum install -y gcc gcc-c++ autoconf libtool
    

    安装apr

    
    

    apache 编译

    ./configure \
    --prefix=/usr/local/apache --sysconfdir=/etc/httpd \
    --enable-so --enable-cgi -enable-ssl --enable-rewrite \
    --with-zlib --with-pcre=/usr/local/pcre \
    --with-apr=/usr/local/apr \
    --with-apr-util=/usr/local/apr-util \
    --enable-mods-shared=most --enable-mpms-shared=all \
    --with-mpm=event
    

    安装PHP教程可参考阿里云官方文档

    https://help.aliyun.com/document_detail/50774.html?spm=5176.doc50700.6.720.1UYs1Q
    

    安装完数据库之后需要给数据库添加远程连接的用户

    1.  create user 用户名@'%'  identified by '密码' ;# 远程登录
    2. create user 用户名@'localhost' identified by '密码'; #本地登录
    

    用户授权
    a.授权格式: grant 权限 on 数据库.* 用户名@登录主机 identified by '密码';

    b.授权数据库的所有权限

    grant all privileges on testDB.* to test@'localhost' identified by  '1234';
    flush privileges; #刷新系统权限表
    

    c.授权部分权限

    grant select,update on testDB.* to  test@'localhost' identified by  '1234';
    flush privileges; #刷新系统权限表
    

    d.授权test用户的所有数据库的某些权限

    grant select,delete,update,create,drop on . to test@'%'  identified by '1234';  #”%” 表示对所有非本地主机授权,不包括localhost
    flush privileges; #刷新系统权限表
    

    删除用户###

    mysql -u root -p
    delete  from  mysql.user where  'test' and  host='localhost';
    flush privileges;
    drop database testDB;
    

    删除账户及权限

    drop user 用户名@’%’;
    drop user 用户名@'localhost';
    

    修改制定用户密码

    mysql -u root -p
    update mysql.user set authentication_string=password('新密码') where user='test' and  host='localhost';
    flush privileges;
    

    相关文章

      网友评论

        本文标题:阿里云ECS上手动部署LAMP

        本文链接:https://www.haomeiwen.com/subject/csbbhxtx.html