浏览代码

Updated nginx config for Symfony (#3162)

* Updated nginx config for Symfony

* Updated the setup script

* Use the DBHOST env var in the deploy config

* Change the database server name

* Replace only db_host, not localhost

* Updated the root dir
Javier Eguiluz 7 年之前
父节点
当前提交
40c6fa2549
共有 2 个文件被更改,包括 33 次插入65 次删除
  1. 28 60
      frameworks/PHP/symfony/deploy/nginx.conf
  2. 5 5
      frameworks/PHP/symfony/setup.sh

+ 28 - 60
frameworks/PHP/symfony/deploy/nginx.conf

@@ -1,37 +1,37 @@
-#user  nobody;
 worker_processes  8;
 
-#error_log  logs/error.log;
-#error_log  logs/error.log  notice;
-#error_log  logs/error.log  info;
-error_log stderr error;
-
-#pid        logs/nginx.pid;
-
-
 events {
-    worker_connections  1024;
+    worker_connections 2048;
+    multi_accept on;
+    use epoll;
 }
 
-
 http {
-    include       /usr/local/nginx/conf/mime.types;
-    default_type  application/octet-stream;
-
-    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
-    #                  '$status $body_bytes_sent "$http_referer" '
-    #                  '"$http_user_agent" "$http_x_forwarded_for"';
+    include /home/vagrant/FrameworkBenchmarks/installs/nginx/conf/mime.types;
+    default_type application/octet-stream;
 
-    #access_log  logs/access.log  main;
     access_log off;
 
-    sendfile        on;
-    #tcp_nopush     on;
-
-    #keepalive_timeout  0;
-    keepalive_timeout  65;
-
-    #gzip  on;
+    sendfile on;
+    tcp_nopush on;
+    tcp_nodelay on;
+    keepalive_timeout 65;
+
+    open_file_cache max=2000 inactive=20s;
+    open_file_cache_valid 60s;
+    open_file_cache_min_uses 5;
+    open_file_cache_errors off; 
+
+    #FastCGI optimizations
+    fastcgi_buffers 256 16k;
+    fastcgi_buffer_size 128k;
+    fastcgi_connect_timeout 30s;
+    fastcgi_send_timeout 60s;
+    fastcgi_read_timeout 60s;
+    fastcgi_busy_buffers_size 256k;
+    fastcgi_temp_file_write_size 256k;
+    reset_timedout_connection on;
+    server_names_hash_bucket_size 100;
 
     upstream fastcgi_backend {
         server 127.0.0.1:9001;
@@ -41,31 +41,7 @@ http {
         listen       8080;
         server_name  localhost;
 
-        #charset koi8-r;
-
-        #access_log  logs/host.access.log  main;
-
-        #location / {
-        #    root   html;
-        #    index  index.html index.htm;
-        #}
-
-        #error_page  404              /404.html;
-
-        # redirect server error pages to the static page /50x.html
-        #
-        #error_page   500 502 503 504  /50x.html;
-        #location = /50x.html {
-        #    root   html;
-        #}
-
-        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
-        #
-        #location ~ \.php$ {
-        #    proxy_pass   http://127.0.0.1;
-        #}
-
-        root /home/tfb/FrameworkBenchmarks/php-symfony/public/;
+        root /home/vagrant/FrameworkBenchmarks/frameworks/PHP/php-symfony/public/;
         index  index.php;
 
         location / {
@@ -78,18 +54,10 @@ http {
             try_files $uri =404;
             fastcgi_pass   fastcgi_backend;
             fastcgi_index  index.php;
-#            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             fastcgi_param  APP_ENV "prod";
-            fastcgi_param  DATABASE_URL "mysql://benchmarkdbuser:benchmarkdbpass@localhost/hello_world";
-            include        /usr/local/nginx/conf/fastcgi_params;
+            fastcgi_param  DATABASE_URL "mysql://benchmarkdbuser:benchmarkdbpass@db_host/hello_world";
+            include        /home/vagrant/FrameworkBenchmarks/installs/nginx/conf/fastcgi_params;
         }
-
-        # deny access to .htaccess files, if Apache's document root
-        # concurs with nginx's one
-        #
-        #location ~ /\.ht {
-        #    deny  all;
-        #}
     }
 }

+ 5 - 5
frameworks/PHP/symfony/setup.sh

@@ -2,9 +2,9 @@
 
 fw_depends mysql php7 nginx
 
-sed -i 's|localhost|'"${DBHOST}"'|g' deploy/nginx.conf
-sed -i 's|root .*/FrameworkBenchmarks/php-symfony| root '"${TROOT}"'|g' deploy/nginx.conf
-sed -i 's|/usr/local/nginx/|'"${IROOT}"'/nginx/|g' deploy/nginx.conf
+sed -i 's|db_host|'"${DBHOST}"'|g' deploy/nginx.conf
+sed -i 's|root .*/FrameworkBenchmarks/frameworks/PHP/php-symfony|root '"${TROOT}"'|g' deploy/nginx.conf
+sed -i 's|/home/vagrant/FrameworkBenchmarks/installs/nginx/|'"${IROOT}"'/nginx/|g' deploy/nginx.conf
 
 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
 php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
@@ -18,5 +18,5 @@ php composer.phar install --no-dev --no-interaction --no-progress --optimize-aut
 php bin/console cache:clear --env=prod --no-debug --no-warmup
 php bin/console cache:warmup --env=prod --no-debug
 
-php-fpm --fpm-config $FWROOT/toolset/setup/linux/languages/php/php-fpm.conf -g $TROOT/deploy/php-fpm.pid
-nginx -c $TROOT/deploy/nginx.conf
+php-fpm --fpm-config ${FWROOT}/toolset/setup/linux/languages/php/php-fpm.conf -g ${TROOT}/deploy/php-fpm.pid
+nginx -c ${TROOT}/deploy/nginx.conf