zoukankan      html  css  js  c++  java
  • Ubuntu18.04 apache2配置ThinkPHP6

    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这样访问

    如果配置了多站点,如/etc/apache2/sites-available/mysite.conf:

    <VirtualHost *:8080>
    <Directory /home/ubuntu/xhadmin/public>

    AllowOverride All
    Options Indexes FollowSymLinks
    Require all granted
    </Directory>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/ubuntu/xhadmin/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    </VirtualHost>

    则一定要执行:

    cd /etc/apache2/sites-available
    sudo a2ensite mysite
    sudo service apache2 reload

  • 相关阅读:
    sqlite 修改 id 自增值
    欧拉图与哈密顿图12:22
    nps 配置 vnc内网穿透
    0 范数、1 范数、2 范数有什么区别?
    相关测试
    golang学习笔记---channel(通道)
    golang学习笔记---pflag包
    Nginx+Keepalived配置Nginx自动启动和7*24不间断服务
    Keepalived+Nginx双机主备配置实践
    虚拟机中使用域名通过宿主window访问
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/12348453.html
Copyright © 2011-2022 走看看