Home >PHP Framework >ThinkPHP >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.
Installing the PHP environment under Linux is very simple, just execute the following command:
Ubuntu:
sudo apt-get install php
CentOS:
yum install php
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
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
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.
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.
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
Under the Linux platform, it is not difficult to install and run the ThinkPHP project. Please pay attention to the following points:
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!