I have an existing server that works well with multiple sites using nginx and ISPconfig. However, I created a new site and want to use Laravel.
I successfully installed Laravel with the help of a composer and got to the familiar welcome blade displayed when visiting mywebsite.com/public
What I want to do next is make some clean URLs. My experience with vhost files is somewhat limited, and I am having configuration problems.
My routes file looks like this:
Route::get('/', function () { return view('welcome'); }); Route::get('/test', function () { return view('test'); });
and I was hoping mywebsite.com/test would display the contents of test.blade.php
I know that I need to do some work with the vhost file before I can expect it to work, but my experience with vhosts is limited and I lost a bit.
My current file is as follows
server { listen *:80; server_name mywebsite.com ; root /var/www/mywebsite.com/web; index index.html index.htm index.php index.cgi index.pl index.xhtml; error_page 400 /error/400.html; error_page 401 /error/401.html; error_page 403 /error/403.html; error_page 404 /error/404.html; error_page 405 /error/405.html; error_page 500 /error/500.html; error_page 502 /error/502.html; error_page 503 /error/503.html; recursive_error_pages on; location = /error/400.html { internal; } location = /error/401.html { internal; } location = /error/403.html { internal; } location = /error/404.html { internal; } location = /error/405.html { internal; } location = /error/500.html { internal; } location = /error/502.html { internal; } location = /error/503.html { internal; } error_log /var/log/ispconfig/httpd/mywebsite.com/error.log; access_log /var/log/ispconfig/httpd/mywebsite.com/access.log combined; location ~ /\. { deny all; access_log off; log_not_found off; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /stats/ { index index.html index.php; auth_basic "Members Only"; auth_basic_user_file /var/www/clients/client1/web5/web/stats/.htpasswd_stats; } location ^~ /awstats-icon { alias /usr/share/awstats/icon; } location ~ \.php$ { try_files /5e26a1d85cb98f7191261e023385e60d.htm @php; } location @php { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/lib/php5-fpm/web5.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; } }
Now on another server I am working with this simple directive
server { root /var/www/public; index index.php index.html index.htm; server_name localhost; location / { try_files $uri $uri/ /index.php$is_args$args; } }
But I'm limited to what I can do with vhost on the current server, since ISPconfig writes most of this for me, and it refuses to write the above configuration, which worked elsewhere. Also I feel that editing the file directly will be bad practice, I will always be on the verge that ISPconfig will overwrite the file for me, so I'm not sure how best to continue this.
My options are just to go and edit vhost and hope for the best, but if I do, how could I make sure ISPconfig cannot overwrite the file without resorting to โhackerโ methods?
Alternatively, is there a configuration that I can enter through ISPconfig that allows me to rewrite the correct paths in a way that suits Laravel? In this case, any directive entered must take precedence over the ~ .php $ sentence, as ISPconfig writes, over any directives entered through the control panel.