Wszystko co dotyczy tworzenia stron WWW.
Awatar użytkownika

winuser

Zasłużony użytkownik
Posty: 1437
Rejestracja: 29 sie 2013, 13:15
    Windows 7 Chrome

Post07 mar 2016, 13:40

Cześć, postawiłem klientowi forum na phpBB używając Apache. Wszystko dobrze działało, ale przy sporym załadowaniu serwera przymulało. Postanowiłem przełączyć na nginx, naczytałem się o nim dużo dobrego w kwestii wydajności. Wszystko działa, ale mam problem z przekierowaniami np do localhost/app.php/rules - nginx wyrzuca błąd 404.
nginx.conf stworzony na podstawie bazowego od phpBB wygląda tak:

Kod: Zaznacz cały

# Sample nginx configuration file for phpBB.
# Global settings have been removed, copy them
# from your system's nginx.conf.
# Tested with nginx 0.8.35.

# If you want to use the X-Accel-Redirect feature,
# add the following to your config.php.
#
#  define('PHPBB_ENABLE_X_ACCEL_REDIRECT', true);
#
# See http://wiki.nginx.org/XSendfile for the details
# on X-Accel-Redirect.

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
	worker_connections 768;
	# multi_accept on;
}

http {

 #
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	 server_tokens off;
	 
	 	include /etc/nginx/mime.types;
	default_type application/octet-stream;
    ##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Catch-all server for requests to invalid hosts.
    # Also catches vulnerability scanners probing IP addresses.
    server {
        # default specifies that this block is to be used when
        # no other block matches.
        listen 80 default;

        server_name bogus;
        return 444;
        root /var/empty;
    }

	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
	

    # If you have domains with and without www prefix,
    # redirect one to the other.
    server {
        # Default port is 80.
        #listen 80;

        server_name myforums.com;

        # A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites:
        rewrite ^ http://www.domena.pl$request_uri permanent;
        # Equivalent to:
        #rewrite ^(.*)$ http://www.doemna.pl$1 permanent;
    }


    }

    # If running php as fastcgi, specify php upstream.
    upstream php {
        server unix:/tmp/php.sock;
    }
}
Plik default (sites-avaiable):

Kod: Zaznacz cały

# You may add here your
# server {
#	...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##


server {
	listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

	root /var/www;
	index index.html index.php index.htm;

	# Make site accessible from http://domena.pl
	server_name domena.pl;
	location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|store) {
        deny all;
        return 403;
    }

    location ~* \.(gif|jpe?g|png|css)$ {
        expires   30d;
    }

	location /doc/ {
		alias /usr/share/doc/;
		autoindex on;
		allow 127.0.0.1;
		allow ::1;
		deny all;
	}

	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
	#location /RequestDenied {
	#	proxy_pass http://127.0.0.1:8080;    
	#}

	#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 /usr/share/nginx/www;
	#}

	# pass the PHP scripts to FastCGI server listening on (.
           location ~ \.php$ {
 try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
     fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    
}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#	listen 80;
#	listen somename:8080;
#	server_name somename alias another.alias;
#	root html;
#	index index.html index.htm;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}


# HTTPS server
#
#server {
#	listen 443;
#	server_name localhost;
#
#	root html;
#	index index.html index.htm;
#
#	ssl on;
#	ssl_certificate cert.pem;
#	ssl_certificate_key cert.key;
#
#	ssl_session_timeout 5m;
#
#	ssl_protocols SSLv3 TLSv1;
#	ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
#	ssl_prefer_server_ciphers on;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}
Support phpBB milczy w kwestii konfiguracji z nginx, dają tylko przykładowe pliki na bazie których stworzyłem co powyżej.

Mam rozwiązanie:
do default dodajemy to:

Kod: Zaznacz cały

location /app.php {
        try_files $uri $uri/ /app.php?$query_string;
}
Laptop: Lenovo ThinkPad T480s | Intel Core i5 8250U | Intel HD 620 | 24GB RAM Hynix | Lexar NM620 NVME 1TB | Windows 10 Pro
Laptop testowy: Lenovo ThinkPad T430 | Intel Core i7 3740QM | Intel HD 4000 | 16GB RAM Hynix | Samsung 850 Pro 256GB | Windows Vista SP3
PC: MSI Z87-G43 | Intel Xeon E3-1240 v3 | nVidia GTX 760 2GB | 20GB RAM Hynix | GoodRAM PX 500 NVME 512GB | Windows 10 Pro
Mobile: Google Pixel 6 | Google Tensor GS101 @2.8 GHz | Mali-G78 MP20 | 8GB RAM | 128GB MMC | Android 14
Serwer: AsRock AD2550-ITX | Intel Atom D2550 | PowerVR SGX545 | 8GB RAM Kingston | WD HDD 500GB | Windows Server 2012 R2 Datacenter
Sieć: Cudy WR3000 Wi-Fi 6 OpenWRT| Huawei HG8010H | Netia 1Gb/s
PlayStation 4 | CUH-1116A | 1TB SSD|

Awatar użytkownika

Onset

Administrator
Posty: 2124
Rejestracja: 06 gru 2008, 19:27
Lokalizacja: multi(0)disk(0)rdisk(0)partition(1)\GDAŃSK partition(2) WARSZAWA
    Windows 7 Chrome

Post07 mar 2016, 21:08

Nginx i PhpBB w bardzo dużym skrócie się nie lubią. Bardzo ciężko dopasować konfigi. Nie jest to niewykonalne, ale najszybciej zrobisz to przez zainstalowanie Ultimate SEO URL. W panelu admina będziesz mieć duże pole tekstowe, a w nim config, który kopiujesz do ustawień nginksa.
Windows 98 supports real multitasking - it can boot and crash simultaneously.
Mój pecet:
Spoiler

Obudowa: Modecom ThinkBell, Zasilacz: OCZ ModXStream 600W, Mobo: MSI B85M-G43, Procesor: Intel Core i5-4570 (Haswell) , Wypalarka: Optiarc DVD RW AD-7173A ATA, Grafika: Gigabyte Radeon R9 270x, HDD1: OCZ Vertex 4 128 GB, HDD2:WDC WD5001AALS-00L3B2 (500GB), HDD3+4: WD1002FAEX-00Z3A0 (RAID-0), RAM: Kingston HyperX Black + Red 16GB (2x4 GB + 2x4GB Dual-Channel) CL9, Mocarne chłodzenie: Scythe Mugen II Rev. B.
Retina MacBook Pro Early 2015:
Spoiler
Intel Core i5-5257u(Broadwell) @ 2.7 Ghz, RAM: 8 GB @ 1866 MHz DDR3, Intel Iris 6100, 128GB PCI-e SSD

Kto jest online

Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 7 gości