Setting Up a ThinkPHP Framework
Overview
ThinkPHP, a free, open-source, fast, and simple object-oriented lightweight PHP development framework, is released under the Apache2 open source protocol and is designed for developing agile web applications and simple enterprise applications. The section guides you through the setup of ThinkPHP using an ECS running CentOS 7.2 on Huawei Cloud.
Prerequisites
- You have purchased an ECS and bound an EIP to it.
- 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 rules Direction
Priority
Action
Type
Protocol & Port
Source Address
Inbound
1
Allow
IPv4
TCP: 22
0.0.0.0/0
Inbound
1
Allow
IPv4
TCP: 443
0.0.0.0/0
Inbound
1
Allow
IPv4
TCP: 8000
0.0.0.0/0
Procedure
- Install PHP.
- Run the following commands to install the EPEL and REMI repositories:
sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
- Run the following commands to enable the PHP 8.0 repository:
sudo yum-config-manager --enable remi-php80
- Run the following commands to install PHP:
sudo yum install -y php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
- Run the following command to check the version of the installed PHP:
Information similar to the following is displayed:
PHP 8.0.30 (cli) (built: Jun 4 2024 15:19:49) ( NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.30, Copyright (c) Zend Technologies
- Run the following commands to install the EPEL and REMI repositories:
- Install Composer.
Composer is a package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.
- Run the following command to install the dependencies required by Composer:
- Run the following commands to install Composer:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
- Run the following command to check the version of the installed Composer:
Information similar to the following is displayed:
Composer version 2.7.7 2024-06-10 22:11:12 PHP version 8.0.30 (/usr/bin/php)
- Install ThinkPHP.
- Use Composer to create a new ThinkPHP application.
Run the following command to create my-thinkphp-app in the current directory and download the core files and dependencies of ThinkPHP:
composer create-project topthink/think my-thinkphp-app
- Run the following commands to switch to the created directory and start the ThinkPHP built-in server for development:
php think run
If information similar to the following is displayed, ThinkPHP has been started:
- After the installation is complete, enter http://ECS EIP:8000 in the address bar of the browser. If the following page is displayed, ThinkPHP has been installed.
- Use Composer to create a new ThinkPHP application.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.