Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Manually Deploying LAMP (CentOS 7.8 PHP 7.0)

Updated on 2024-11-04 GMT+08:00

Overview

LAMP is a web application platform consisting of Linux, Apache, MySQL, and PHP.

The best practices for Huawei Cloud ECS guide you through the deployment of LAMP on a Linux ECS. The CentOS 7.8 64bit OS is used as an example in this section.

Prerequisites

  1. The ECS has an EIP bound.
  2. The rule listed in the following table has been added to the security group which the target ECS belongs to. For details, see Adding a Security Group Rule.
    Table 1 Security group rule

    Direction

    Priority

    Action

    Type

    Protocol & Port

    Source Address

    Inbound

    1

    Allow

    IPv4

    TCP: 80

    0.0.0.0/0

  3. The image source has been updated to a Huawei Cloud image source. For details, see How Can I Use an Automated Tool to Configure a Huawei Cloud Image Source (x86_64 and Arm)? This facilitates obtaining and updating the system and software.

Resource Planning

Table 2 lists the resource configuration and software versions used in this practice. The commands and parameters may vary according to the hardware specifications or software versions you would use.

Table 2 Resources and costs

Resource

Description

Cost

ECS

  • Billing mode: pay-per-use
  • AZ: AZ1
  • Flavor: c7.large.2
  • Image: CentOS 7.8 64bit
  • System disk: 40 GiB
  • EIP: Auto assign
  • EIP type: Dynamic BGP
  • Billed by: Traffic
  • Bandwidth: 5 Mbit/s

The following resources generate costs:

  • ECSs
  • EVS disks
  • EIPs

For billing details, see Billing Modes.

Apache

An open-source web server

Free

MySQL

An open-source relational database software

Download URL:

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

Free

PHP

An open-source software used for web development

Download URL:

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

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

Free

Procedure

  1. Install Apache.

    1. Log in to the ECS.
    2. Run the following commands as user root to update the software package and install Apache:

      yum -y update

      yum -y install httpd

    3. Run the following command to check the version of the installed Apache:

      httpd -v

      Information similar to the following is displayed:

      Server version: Apache/2.4.6 (CentOS)
      Server built:  May 30 2023 14:01:11
    4. Run the following commands in sequence to start Apache and enable it to start automatically upon ECS startup:

      systemctl start httpd

      systemctl enable httpd

    5. Enter http://Server IP address in the address bar of the browser to access Apache. If the following page is displayed, Apache has been installed.

  2. Install MySQL.

    1. Run the following commands in sequence to install MySQL:

      wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

      yum -y install mysql57-community-release-el7-10.noarch.rpm

      yum -y install mysql-community-server --nogpgcheck

    2. Run the following command to check the version of the installed MySQL:

      mysql -V

      Information similar to the following is displayed:

      mysql  Ver 14.14 Distrib 5.7.44, for Linux (x86_64) using  EditLine wrapper
    3. Run the following commands in sequence to start MySQL and enable it to start automatically upon ECS startup:

      systemctl start mysqld

      systemctl enable mysqld

    4. Run the following command to check the MySQL status:

      systemctl status mysqld.service

      [root@ecs-adc3 ~]# systemctl status mysqld.service
      ● mysqld.service - MySQL Server
         Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
         Active: active (running) since Tue 2023-10-31 19:33:40 CST; 36s ago
           Docs: man:mysqld(8)
                 http://dev.mysql.com/doc/refman/en/using-systemd.html
       Main PID: 7916 (mysqld)
         CGroup: /system.slice/mysqld.service
                 └─7916 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
      
      Aug 16 19:33:35 ecs-adc3 systemd[1]: Starting MySQL Server...
      Aug 16 19:33:40 ecs-adc3 systemd[1]: Started MySQL Server.
    5. Run the following commands to obtain the root user's password that is automatically set during MySQL installation:

      grep 'temporary password' /var/log/mysqld.log

      Information similar to the following is displayed:
      2023-10-31T11:53:08.691748Z 1 [Note] A temporary password is generated for root@localhost: 2YY?3uHUA?Ys
    6. Run the following command and follow the prompts to harden MySQL:

      mysql_secure_installation

      Securing the MySQL server deployment.
      
      Enter password for user root:    #Enter the obtained password of user root.
      The existing password for the user account root has expired. Please set a new password.
      
      New password:  #Enter a new password of user root.
      
      Re-enter new password:   #Enter the new password again.
      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) : N   #Press N.
      
       ... skipping.
      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   #Press Y to remove anonymous users.
      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? (Press y|Y for Yes, any other key for No) : Y   #Press Y to disallow remote logins of user root.
      Success.
      
      By default, MySQL 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? (Press y|Y for Yes, any other key for No) : Y   #Press Y to delete the test database and remove access to it.
       - 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? (Press y|Y for Yes, any other key for No) : Y   #Press Y to reload privilege tables.
      Success.
      
      All done!

  3. Install PHP.

    1. Run the following commands to install PHP 7 and required PHP extensions:

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

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

      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

    2. Run the following command to check the version of the installed PHP:

      php -v

      Information similar to the following is displayed:

      PHP 7.0.33 (cli) (built: Dec 6 2018 22:30:44) ( NTS )
      Copyright (c) 1997-2017 The PHP Group
      Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    3. Run the following commands to start PHP and enable it to start automatically upon ECS startup:

      systemctl start php-fpm

      systemctl enable php-fpm

  4. Test the LAMP deployment.

    1. Create the info.php test file in /var/www/html/.
      1. Run the following command to create and open the info.php test file:

        vim /var/www/html/info.php

      2. Press i to enter insert mode.
      3. Modify the info.php file and add the following to the file:
        <?php
         phpinfo();
        ?>
      4. Press Esc to exit insert mode. Then, enter :wq to save the settings and exit.
    2. Run the following command to restart Apache:

      systemctl restart httpd

    3. Enter http://Server IP address/info.php in the address bar. If the following page is displayed, the LAMP environment has been set up.

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback