![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
Mam taki problem ponieważ mam VPS na ubuntu i zainstalowałem tam MYSQL + Nginx + PHP5. Strona wszystko ładnie śmiga tylko zamiast odtwarzać pliki .php ten je pobiera. Wiecie może jak to rozwiązać ? |
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Pokaż konfigurację vhostów.
Ten post edytował by_ikar 28.11.2014, 18:51:05 |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 623 Pomógł: 144 Dołączył: 22.12.2010 Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]()
Post
#5
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Kod ls -l /etc/nginx/sites-enabled/ wylistuje ci listę wszystkich symlinków które będą wskazywały na "vhsoty" które masz włączone. |
|
|
![]()
Post
#6
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Wpisałem to do konsoli i wyskoczyło takie coś :
lrwxrwxrwx 1 root root 34 Nov 28 13:31 default -> /etc/nginx/sites-available/default @Edit Takie coś mam jak wpiszę top : http://wklej.org/id/1541605/ Ten post edytował Gruchol 28.11.2014, 19:47:09 |
|
|
![]()
Post
#7
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Więc twój default w katalogu sites-available jest twoim vhostem, przeklej jego zawartość. top to jest taki odpowiednik menadżera zadań z windowsa, więc nie musisz pokazywać co tam jest
![]() |
|
|
![]()
Post
#8
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Cytat # 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 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } 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/html; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_index index.php; # 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 8000; # 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; # } #} |
|
|
![]()
Post
#9
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Odkomentuj ten kawałek:
Kod # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_index index.php; # include fastcgi_params; #} Czyli powinno wyglądać to tak: Kod # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } I zresetuj nginxa: Kod sudo service nginx restart
|
|
|
![]()
Post
#10
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Nadal pobiera plik .php :/
http://185.38.249.37/test.php |
|
|
![]()
Post
#11
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
To jeszcze przeklej plik z tej lokalizacji:
Kod /etc/nginx/fastcgi_params
|
|
|
![]()
Post
#12
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Cytat fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param HTTPS $https; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; |
|
|
![]()
Post
#13
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Ahh sry mój błąd, tamten kawałek co odkomentowałeś, to odkomentowana jest o jedna linijka za dużo:
Kod # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php5-fpm: #fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } EDIT: dobra, teraz widzę dlaczego tak to działa, spróbuj tego: Kod location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } Tzn podmień tamto wcześniejsze co odkomentowałeś i ofc zrestartuj jeszcze raz nginx'a. Ten post edytował by_ikar 28.11.2014, 20:11:28 |
|
|
![]()
Post
#14
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Teraz mój vhost wygląda tak :
Cytat # 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 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } 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/html; #} location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } # 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 8000; # 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; # } #} I teraz wyświetla się takie coś : http://185.38.249.37/test.php Bad Gateway A zawartość test.php to : Cytat <?php
phpinfo(); ?> Ten post edytował Gruchol 28.11.2014, 20:17:19 |
|
|
![]()
Post
#15
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Ok więc polećmy po kolei, edytuj ten plik:
Kod /etc/php5/fpm/pool.d/www.conf I upewnij się że Kod listen ma taką wartość:Kod listen = /var/run/php5-fpm.sock Jeżeli nie ma to podmień na tą i jeżeli podmieniasz to zrestartuj fpm'a: Kod sudo service php5-fpm restart Następnie ten plik: /etc/nginx/sites-avaliable/default podmień jego zawartość na: Kod server { listen 80; root /usr/share/nginx/www; index index.php index.html index.htm; server_name localhost; location / { try_files $uri $uri/ /index.html; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } Potem zrestartuj nginxa. |
|
|
![]()
Post
#16
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Czyli mam usunąć cały plik default i wkleić to co dałeś tak?
|
|
|
![]()
Post
#17
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Tak. To jest w zasadzie prawie to samo, z tą różnicą że nie ma komentarzy.
Ten post edytował by_ikar 28.11.2014, 20:38:02 |
|
|
![]()
Post
#18
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
W /etc/php5/fpm/pool.d/www.conf było ok.
Podmieniłem default i teraz jest takie coś : Cytat 404 Not Found
nginx/1.4.1 (Ubuntu) |
|
|
![]()
Post
#19
|
|
![]() Grupa: Zarejestrowani Postów: 1 798 Pomógł: 307 Dołączył: 13.05.2009 Skąd: Gubin/Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Document root jest niepoprawny, wydawało mi się że tam było www, a jednak u ciebie jest html..
![]() Kod root /usr/share/nginx/www; podmień na: Kod root /usr/share/nginx/html; i zrestartuj nginxa. |
|
|
![]()
Post
#20
|
|
Grupa: Zarejestrowani Postów: 242 Pomógł: 0 Dołączył: 28.11.2014 Ostrzeżenie: (0%) ![]() ![]() |
Wielkie dzięki działa super !
Tylko mam jeszcze jeden problemik tyle że teraz z czymś innym :X Po instalacji phpmyadmina wyskakuje cały czas Welcome to nginx. http://185.38.249.37/phpmyadmin @Edit Aha i jak instalowałem phpmyadmin i się pytało o apache czy lighttpd to kliknąłem ESC Ten post edytował Gruchol 28.11.2014, 20:54:15 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 28.06.2025 - 13:21 |