Explorar o código

activated php-fpm for default nginx conf

Bachir Soussi Chiadmi %!s(int64=6) %!d(string=hai) anos
pai
achega
10738b8897

+ 22 - 14
assets/nginx-default.conf → assets/default.nginxconf

@@ -41,7 +41,7 @@ server {
 	root /var/www/html;
 
 	# Add index.php to the list if you are using PHP
-	index index.html index.htm index.nginx-debian.html;
+	index index.html index.htm index.nginx-debian.html index.php;
 
 	server_name _;
 
@@ -52,22 +52,30 @@ server {
 	}
 
 	# pass PHP scripts to FastCGI server
-	#
-	#location ~ \.php$ {
-	#	include snippets/fastcgi-php.conf;
-	#
-	#	# With php-fpm (or other unix sockets):
-	#	fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
-	#	# With php-cgi (or other tcp sockets):
-	#	fastcgi_pass 127.0.0.1:9000;
-	#}
+	location ~ \.php$ {
+		fastcgi_pass unix:/run/php/php7.0-fpm.sock;
+		fastcgi_index index.php;
+		include fastcgi_params;
+		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+	}
 
 	# deny access to .htaccess files, if Apache's document root
 	# concurs with nginx's one
-	#
-	#location ~ /\.ht {
-	#	deny all;
-	#}
+	location ~ /\.ht {
+		deny all;
+	}
+
+  ## Images and static content is treated different
+  location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
+    access_log        off;
+    expires           max;
+  }
+
+	location ~ /(libraries|setup/frames|setup/libs) {
+		deny all;
+		return 404;
+	}
+
 }
 
 

+ 0 - 0
assets/nginx-drupal.conf → assets/drupal.nginxconf


+ 1 - 1
assets/nginx-phpmyadmin.conf

@@ -9,7 +9,7 @@ server {
     ## Images and static content is treated different
     location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
       access_log        off;
-      expires           30d;
+      expires           max;
     }
 
     location ~ /\.ht {

+ 0 - 0
assets/nginx-php-fpm.conf → assets/simple-phpfpm.nginxconf


+ 24 - 21
install-debian-server.sh

@@ -296,23 +296,6 @@ if [ "$lemp" = "y" ]; then
   systemctl restart mariadb.service
   echo "\033[92;1mmysql installed\033[Om"
 
-  echo '\033[35m
-      _   __      _
-     / | / /___ _(_)___  _  __
-    /  |/ / __ `/ / __ \| |/_/
-   / /|  / /_/ / / / / />  <
-  /_/ |_/\__, /_/_/ /_/_/|_|
-        /____/
-  \033[0m'
-  echo "\033[35;1mInstalling Nginx \033[0m"
-  sleep 3
-  apt-get --yes --force-yes install nginx
-  cp "$_cwd"/assets/nginx.conf /etc/nginx/conf.d/
-
-  systemctl enable nginx
-  systemctl restart nginx
-  echo "\033[92;1mNginx installed\033[Om"
-
   echo '\033[35m
       ____  __  ______
      / __ \/ / / / __ \
@@ -345,6 +328,24 @@ if [ "$lemp" = "y" ]; then
 
   echo "\033[92;1mphp installed\033[Om"
 
+  echo '\033[35m
+      _   __      _
+     / | / /___ _(_)___  _  __
+    /  |/ / __ `/ / __ \| |/_/
+   / /|  / /_/ / / / / />  <
+  /_/ |_/\__, /_/_/ /_/_/|_|
+        /____/
+  \033[0m'
+  echo "\033[35;1mInstalling Nginx \033[0m"
+  sleep 3
+  apt-get --yes --force-yes install nginx
+  mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori
+  cp "$_cwd"/assets/default.nginxconf /etc/nginx/sites-available/default
+
+  systemctl enable nginx
+  systemctl restart nginx
+  echo "\033[92;1mNginx installed\033[Om"
+
   echo '\033[35m
              __          __  ___      ___       __          _
       ____  / /_  ____  /  |/  /_  __/   | ____/ /___ ___  (_)___
@@ -355,10 +356,11 @@ if [ "$lemp" = "y" ]; then
   \033[0m'
   echo "\033[35;1mInstalling phpMyAdmin \033[0m"
   apt-get --yes --force-yes install phpmyadmin
-  cp "$_cwd"/assets/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
-  ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
+  ln -s /usr/share/phpmyadmin /var/www/html/
+  # cp "$_cwd"/assets/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf
+  # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
 
-  echo "\033[35;1msecuring phpMyAdmin \033[0m"
+  # echo "\033[35;1msecuring phpMyAdmin \033[0m"
   # sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php\nAllowOverride all/"
   # cp "$_cwd"/assets/phpmyadmin_htaccess > /usr/share/phpmyadmin/.htaccess
   # echo -n "define a user name for phpmyadmin : "
@@ -443,8 +445,9 @@ if [ "$lemp" = "y" ]; then
       fi
     fi
     done
+    # TODO ask for simple php conf or drupal conf
 
-    cp "$_cwd"/assets/nginx.conf /etc/nginx/sites-available/"$_host_name".conf
+    cp "$_cwd"/assets/simple-phpfpm.nginxconf /etc/nginx/sites-available/"$_host_name".conf
     sed -ir "s/yourdomain\.ltd/$_host_name/g" /etc/nginx/sites-available/"$_host_name".conf
 
     mkdir -p /var/www/"$_host_name"/public_html