How to run thinkphp under linux
How to run the ThinkPHP project under the Linux platform?
ThinkPHP is a very excellent PHP development framework. It greatly improves PHP development efficiency and code quality, and is favored by the majority of developers. How to run the ThinkPHP project on the Linux platform? Below, I will give you a detailed introduction.
- Install the PHP environment
Installing the PHP environment under Linux is very simple, just execute the following command:
Ubuntu:
sudo apt-get install php
CentOS:
yum install php
- Install Apache or Nginx
under Linux Commonly used web servers include Apache and Nginx. The following describes how to install them.
2.1 Apache installation
Ubuntu:
sudo apt-get install apache2
CentOS:
yum install httpd
2.2 Nginx installation
For users who use Nginx, you can choose to install Nginx and use the php-fpm module to execute PHP code. This method is more efficient than Apache.
Ubuntu:
sudo apt-get install nginx php-fpm
CentOS:
yum install nginx php-fpm
- Install Composer
ThinkPHP 5 uses Composer as the package management tool. If Composer has been installed, you can skip this step.
Ubuntu:
sudo apt-get install composer
CentOS:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
- Install ThinkPHP
In Linux, there are many ways to install ThinkPHP. Two are introduced below: Composer installation and manual installation.
4.1 Composer installation
Execute the following command in the command line:
composer create-project topthink/think tp5 --prefer-dist
Among them, tp5 is the project name, --prefer-dist means to install using compressed package.
After the installation is completed, you can start the PHP built-in web server in the project root directory through the command line and execute the following command:
php think run
4.2 Manual installation
Manual installation requires first downloading and decompressing ThinkPHP to the specified directory, and then configuring the rewrite rules (you can use .htaccess or nginx.conf). After the configuration is completed, it can be run.
- Configuring the database
Under Linux, ThinkPHP uses the MySQL database by default. Database connection information needs to be set in the configuration file.
In the project root directory, open the application/database.php file and fill in the correct database connection information.
- Run the project
After the configuration is completed, you can access the project through a web browser.
Rule: http(s)://your domain name or IP/project name/module name/controller name/method name
For example:
http:/ /localhost/tp5/index/index/hello
- Summary
Under the Linux platform, it is not difficult to install and run the ThinkPHP project. Please pay attention to the following points:
- Install PHP environment;
- Install Apache or Nginx;
- Install Composer;
- Install ThinkPHP;
- Configure database;
- Run the project.
I hope that the introduction in this article can help you better run ThinkPHP projects under Linux systems.
The above is the detailed content of How to run thinkphp under linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









