如何在Laravel旁边安装其他应用程序


How do I install other applications alongside Laravel?

我正在Laravel 5.2中构建一个网站,而不是从头开始构建一个论坛,我希望安装一个像SMF这样的论坛。

Laravel目前在我的web服务器的根目录中,我希望将其保存在那里,因为我希望在文件夹中安装SMF。

例如:www.example.com/smf

我想把它安装在Laravel的/public文件夹中,但我担心它们会相互冲突。/public文件夹是安装SMF的正确位置吗?我应该使用路由指向SMF文件夹吗?

服务器:D.O液滴通过Laravel Forge

您需要在Laravel相关规则之前为要使用的文件夹添加自定义规则:

location /smf/index.php(/.*)?$ {        
    fastcgi_split_path_info ^(/smf/index.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 1000;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    include fastcgi_params;
}
location /smf/ { 
    if (!-e $request_filename) {
            rewrite ^.*$ /smf/index.php last;    
        }
    try_files $uri $uri/ smf/index.php?args; 
}

请在这里查找示例nginx配置文件。

您可以使用Nginx将www.example.com/smf重定向到SMF安装。要做到这一点,请将其添加到您的server块:

location /smf {
    # nginx will concatenate the string above with the root value
    # so your SMF files should be in "/path/to/smf/parent/dir/smf".
    # Make sure that Nginx can access them.
    root "/path/to/smf/parent/dir";
    # change this config to suit your needs
    index  index.php index.html index.htm;
    location ~ '.php$ {
        # Here use the same config from the server block that allows you
        # to execute PHP scripts
        fastcgi_pass   127.0.0.1:9123;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

我应该补充几点:

  • 在编辑配置文件之前先备份配置文件
  • 尽管我已经尝试了上面的代码(并且它在我的机器上有效™)我必须说,我不是一个Nginx专家