nginx と ISPconfig を使用して多数のサイトをホストしている既存のサーバーがあります。しかし、私は新しいサイトを作成し、Laravel を使用したいと考えています。
composer を使用して Laravel を正常にインストールし、mywebsite.com/public にアクセスしたときに、おなじみのウェルカム ブレードが表示されるようになりました。
次にやりたいことは、いくつかのきれいな URL を作成することです。vhost ファイルに関する私の経験はいくぶん限られており、構成に少し問題があります。
私のルートファイルは次のようになります
Route::get('/', function () {
return view('welcome');
});
Route::get('/test', function () {
return view('test');
});
そして、mywebsite.com/test に test.blade.php の内容が表示されることを望んでいました。
これが機能することを期待する前に、vhost ファイルでいくつかの作業を行う必要があることは承知していますが、vhosts の経験は限られているため、少し途方に暮れています。
私の現在のファイルは次のようになります
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;
}
}
今、別のサーバーで、この単純なディレクティブでこれを機能させています
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;
}
}
しかし、ISPconfig がそのほとんどを書き込み、他の場所で機能した上記の構成を書き込むことを拒否するため、現在のサーバーの vhost でできることは限られています。また、ファイルを直接編集するのは悪い習慣だと思います.ISPconfigがファイルを書き換えてくれるので、常に緊張しているので、これをどのように進めるのが最善かわかりません.
私のオプションは、先に進んで仮想ホストを編集し、最善を尽くすことですが、そうする場合、「ハック」メソッドに頼らずにISPconfigがファイルを上書きできないようにするにはどうすればよいですか?
あるいは、Laravel に合った方法で適切に書き換えを行うことができる ISPconfig 経由で入力できる構成はありますか? この場合、入力されたディレクティブは~ .php$句よりも優先される必要があります。これは、コントロール パネル経由でディレクティブが入力される前に ISPconfig によって書き込まれるためです。