1. 程式人生 > >ubuntu wordpress and laravel ngnix配置

ubuntu wordpress and laravel ngnix配置

配置路徑/etc/nginx/sites-enabled

server {
    listen 80;
    listen [::]:80;

    server_name www.mayixiaocao.cn mayixiaocao.cn;

    root /var/www/wordpress;
    index index.html index.php;
    
    location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param  HTTPS              off;
            fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;
            #fastcgi_param HTTP_X-Accel-Mapping /udisk=/var/www/edusoho/app/data/udisk;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 8 128k;
            include fastcgi.conf;
            fastcgi_intercept_errors on;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        gzip off;
        }
    # 禁止使用者上傳目錄下所有.php檔案的訪問,提高安全性
        location ~ ^/files/.*\.(php|php7.0)$ {
            deny all;
        }
    
    location ~ \.user\.ini$ {
        deny all;
    }
}
server {
	listen 80;
	listen [::]:80;

	server_name www.mayixiaocao.cn;

	root /var/www/laravel/public;

	add_header X-Frame-Options "SAMEORIGIN";
    	add_header X-XSS-Protection "1; mode=block";
    	add_header X-Content-Type-Options "nosniff";	

	index index.html index.php index.htm;
	charset utf-8;	

	location / {
		try_files $uri $uri/ /index.php?$query_string;
	}
	
	location = /favicon.ico { access_log off; log_not_found off; }
    	location = /robots.txt  { access_log off; log_not_found off; }
	
	error_page 404 /index.php;
	
	location ~ \.php$ {
		fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
        	fastcgi_split_path_info ^(.+\.php)(/.+)$;
        	fastcgi_index index.php;
        	include fastcgi_params;
        }

	
	location ~ /\.(?!well-known).* {
        	deny all;
    	}

}