我在Laravel 5.2中建立一个网站,而不是从头开始建立一个论坛,我希望安装一个像SMF这样的网站。
Laravel当前位于我的Web服务器的根目录中,我希望将其保留在那里,因为我希望在一个文件夹中安装SMF。
例如:www.example.com/smf
我想在Laravel的/public
文件夹中安装它,但我担心它们会相互冲突。 /public
文件夹是否是安装SMF的正确位置,我应该使用路由指向SMF文件夹吗?
服务器:D.O Droplet通过Laravel Forge
答案 0 :(得分:1)
您可以使用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;
}
}
我应该补充几件事:
答案 1 :(得分:1)
您需要为要使用之前 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 config file here。