My vagrant box doesn’t parse PHP-files for Bolt CMS.
I’m a dev for years now, been working in Vagrant since about 5 years, and never had serious problems.
I wanted to give Bolt CMS a try, but when I fire my browser to the correct url (http://sallys.local:8000) it always wants to download the index-file (or any other file) instead of parsing it.
My vagrant-box is updated to the latest version 8.10, I use Nginx, but it seems as Nginx isn’t called. I activated the acces-log and it shows no entries. For my other projects, same box, it does.
The Nginx-config for this one is:
server {
listen 80;
listen 443 ssl;
server_name sallys.local;
root "/home/vagrant/sallys/public";
index index.html index.htm index.php app.php;
charset utf-8;
location / {
try_files $uri $uri/ /app.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# access_log off;
access_log /var/log/nginx/sallys.local-ssl-acces.log;
error_log /var/log/nginx/sallys.local-ssl-error.log error;
sendfile off;
client_max_body_size 100m;
# DEV
location ~ ^/(app_dev|config).php(/|$) {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
# PROD
location ~ ^/app.php(/|$) {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
location ~ /.ht {
deny all;
}
ssl_certificate /etc/nginx/ssl/sallys.local.crt;
ssl_certificate_key /etc/nginx/ssl/sallys.local.key;
}
I have a similar setup for my other projects, and they all respond on port 8000. And parse PHP-files correctly. This seems to be a noob-problem. But I can’t find the problem in here.
when I’m using the built-in server, it does work. So there must be a problem with Nginx.
Any one any idea?
Thanks
Tim
2
Answers
Thanks for pointing me out, Gawain. I tried your solution, but it didn't work. I removed the entries in my homestead file, reprovisioned vagrant, ..... and it works...
There is a new config generated:
It looks like that is an Nginx site config for a Symfony 2/3 set-up (Symfony 4 is simpler FWIW), so it won’t work “out of the box”, so to speak.
My guess would be the
location / {}
as that is referencingapp.php
, and by default, a Bolt install will useindex.php
as the index file in the webroot.There is a specific documentation page in Bolt’s documentation that covers Nginx configuration specifically for a Bolt install, and I’d guess that’d be enough for your use case.