zoukankan      html  css  js  c++  java
  • 阿里云搭建lamp环境

    前提条件

    • 已注册阿里云账号。如还未注册,请先完成账号注册
    • 已完成实名认证。如还未认证,请先完成实名认证
    • 已创建ECS实例并为实例分配公网IP地址,具体操作请参见创建方式导航
      本篇教程使用以下配置的ECS实例:
      • 实例规格:ecs.c6.large
      • 操作系统:公共镜像CentOS 7.8 64位
      • 网络类型:专有网络VPC
      • IP地址:公网IP
    • 已在实例安全组的入方向添加安全组规则并放行22、80端口。具体操作请参见添加安全组规

    工具/原料

    • centos系统一台
    • 安全组放行80,22端口
    • 关闭防火墙和SELinux

    方法/步骤

    1.通过xshell 运行命令cat /etc/redhat-release查看系统版本

    2.运行systemctl status firewalld命令查看当前防火墙的状态。如果防火墙的状态参数是inactive,则防火墙为关闭状态.就执行下一步。如果防火墙的状态参数是active,则防火墙为开启状态。临时关闭防火墙,运行命令systemctl stop firewalld,永久关闭防火墙,运行命令systemctl disable firewalld。

    3.更新下yum源 yum update -y

    4.利用yum命令安装Apache执行命令,yum -y install httpd

    5.启动httpd并且设置为它开机启动,systemctl start httpd    【启动httpd命令】systemctl enable httpd 【设置httpd开机启动】

    6.我们这里可通过俩个命令查看是否启动和开机启动;systemctl status httpd      【查看是否启动命令】systemctl is-enabled httpd 【查看是否开机启动(输出enabled已经成功)】

    7.安装成功后,在浏览器地址栏输入你的服务器IP地址出现下图说明你的httpd已经成功安装,例如我这里:47.113.203.33

    8.安装数据库Mariadb它是MySQL的一个分支几乎兼容mysql所有功能,执行下面命令;yum -y install mariadb-server mariadb

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

    systemctl start mariadb 

    systemctl enable mariadb

    systemctl status mariadb

    systemctl is-enabled mariadb

    10.下面配置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!

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

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

    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;            【命令显示数据库列表】

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

    12.安装PHP,执行命令;yum -y install php

    13.查看所有组件,执行命令;yum search php

    14.选择所需组件进行安装,执行命令;

    yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

    15.完成后我们可以新建一个PHP页面来查看我们安装的组件,执行命令;

    vim /var/www/html/info.php

     #打开后按键盘字母 i  

    #编辑为以下内容;

     <?php

    phpinfo();

    ?>

     #编辑完后按键盘 Esc 在输入  :  最后 wq!   回车。

    #vim使用方法可自行百度,不作详细解释

    16.最后重启的httpd服务,执行命令;

    systemctl restart httpd

    打开浏览器输入:47.113.203.33/info.php(即IP地址 / 和文件名)

    #看到页面证明您的LAMP环境搭建httpd发布目录默认在/var/www/html/

    安装phpMyAdmin

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

    mkdir -p /var/www/html/phpmyadmin

    2.运行以下命令下载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
    3.运行以下命令复制phpMyAdmin文件到准备好的数据存放目录。
    mv phpMyAdmin-4.0.10.20-all-languages/*  /var/www/html/phpmyadmin
    4在本地机器浏览器地址栏,输入http://实例公网 IP/phpmyadmin并按Enter键,访问phpMyAdmin登录页面。




  • 相关阅读:
    [求助] win7 x64 封装 出现 Administrator.xxxxx 的问题
    [经验] Win7减肥攻略(删文件不删功能、简化优化系统不简优化性能)
    [原创] Easy SysLite V1.2 (2016.5.29更新,新增加WIN10支持,一个程序适配所有系统减肥)
    [经验] 新版SkyIAR、Easy Image X在有些PE里不能运行的解决办法
    [教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續)
    [讨论] 这几天来封装Win7用户配置文件丢失的解决方法个人心得
    [原创] 【2014.12.02更新网盘链接】基于EasySysprep4.1的 Windows 7 x86/x64 『视频』封装
    [分享] 封装工具ES4配置文件解释
    [分享] 史上最简单的封装教程,五分钟学会封装系统(以封装Windows 7为例)
    [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 )
  • 原文地址:https://www.cnblogs.com/xiaoqiangjun/p/13962514.html
Copyright © 2011-2022 走看看