首页 > Web开发 > 详细

Ubuntu18.04 apache2配置ThinkPHP6

时间:2020-02-23 12:04:02      阅读:204      评论:0      收藏:0      [点我收藏+]

1.修改apache2的配置文件 /etc/apache2/apache2.conf

修改根目录和AllowOverride权限

<Directory /home/ubuntu/thinkphp/tp6/think/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

 

2.修改/etc/apache2/sites-available/000-default.conf中的根目录

 

DocumentRoot /home/ubuntu/thinkphp/tp6/think/public

 

3.修改ThinkPHP public目录下的.htaccess文件:

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

 

4.执行

sudo a2enmod rewrite

 

5.重启服务

 

sudo service apache2 restart

 

可以这样访问了:

http://111.229.200.158/Index/myhello

 

注意,自带的hello因为路由问题不能http://111.229.200.158/Index/hello这样访问

Ubuntu18.04 apache2配置ThinkPHP6

原文:https://www.cnblogs.com/GarfieldTom/p/12348453.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!