From 89fc49582cd6f4aa618235bec2d509dc4e17cdbf Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 17 Sep 2017 20:22:23 +0700 Subject: [PATCH] Improved Nginx virtual host config example (documentation). --- docs/en/virtual_host.md | 50 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/docs/en/virtual_host.md b/docs/en/virtual_host.md index 2a51e0df..7c266f7c 100644 --- a/docs/en/virtual_host.md +++ b/docs/en/virtual_host.md @@ -10,21 +10,35 @@ Nginx Example ``` server { - ... standard virtual host ... + charset utf-8; + client_max_body_size 128M; - location / { - try_files $uri @php-censor; - } + listen *:80; - location @php-censor { - # Pass to FastCGI: - fastcgi_pass unix:/path/to/phpfpm.sock; - fastcgi_index index.php; - fastcgi_buffers 256 4k; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root/index.php; - fastcgi_param SCRIPT_NAME index.php; - } + server_name php-censor.local www.php-censor.local; + root /var/www/php-censor.local/public; + + #access_log /var/www/php-censor.local/runtime/nginx_access.log; + error_log /var/www/php-censor.local/runtime/nginx_errors.log warn; + + location ~* \.(htm|html|xhtml|jpg|jpeg|gif|png|css|zip|tar|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|wav|bmp|rtf|swf|ico|flv|txt|docx|xlsx)$ { + try_files $uri @fpm; + expires 30d; + } + + location / { + try_files $uri @fpm; + } + + location @fpm { + fastcgi_pass unix:/var/run/php/php-fpm.sock; + + include fastcgi_params; + + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root/index.php; + fastcgi_param SCRIPT_NAME index.php; + } } ``` @@ -47,15 +61,17 @@ following to a `.htaccess` file in your PHP Censor `/public` directory. - Edit virtual host in apache2. ``` - ServerAdmin user@domain.com + ServerAdmin admin@php-censor.local DocumentRoot /var/www/php-censor.local/public - ServerName php-censor.local + ServerName php-censor.local + ServerAlias www.php-censor.local - + Options Indexes FollowSymLinks AllowOverride All Require all granted + ErrorLog ${APACHE_LOG_DIR}/php-censor-error_log CustomLog ${APACHE_LOG_DIR}/php-censor-access_log combined @@ -63,7 +79,7 @@ following to a `.htaccess` file in your PHP Censor `/public` directory. - Add in /etc/hosts ``` -127.0.0.1 php-censor.local +127.0.0.1 php-censor.local www.php-censor.local ``` Built-in PHP Server Example