以下是在Linux服务器上部署ThinkPHP的通用步骤:
php-fpm
、php-mysql
等)、Composer、MySQL/MariaDB。try_files $uri $uri/ /index.php?$query_string;
规则。composer create-project topthink/think tp6
,或手动上传项目文件至服务器。/var/www/html/tp6
)。.env
文件,配置数据库连接信息(主机、端口、用户名、密码等)。php think migrate
)。runtime
目录可写:chmod -R 755 runtime
,并设置正确所有者(如www-data
或nginx
用户)。sudo systemctl restart nginx php-fpm
。http://服务器IP/项目路径
,查看是否正常显示。注意事项:
APP_DEBUG=false
)并限制.env
文件访问。参考来源: