簡體   English   中英

Nginx和Apache(PHP)

[英]nginx and apache (php)

我已經設置了nginx,但是現在虛擬主機上的每個* .php文件都返回500內部服務器錯誤。

server {
listen   tucnak.dev:80; ## listen for ipv4; this line is default and implied

root /home/tucnak/Web/Lab;
index index.php index.html;

server_name tucnak.dev;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to index.html
    try_files $uri $uri/ /index.html;
}

location /doc {
    root /usr/share;
    autoindex on;
    allow 127.0.0.1;
    deny all;
}

location /images {
    root /usr/share;
    autoindex off;
}

#error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/www;
}

location ~ \.php$ {
    proxy_pass http://127.0.0.1;
}

location  ~ \.php$ {
        set $php_root /home/tucnak/Web/Lab;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

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

我的錯誤在哪里? 我的php文件是完全正確的!

 <?php echo("Hello!"); ?>

我真的是nginx的新手,需要幫助。 apache2之后-我很困惑!

UPD:我認為nginx無法成功提供針對Apache的查詢。 我不知道該如何解決。

我一直在使用Google搜索和測試所有發行版教程,但都無濟於事。 因此,我了解到必須向您的發行版咨詢正確的文檔,否則它將根本無法正常工作。 所以我找到了這個

我有運行Apache 2.2的RHE5.7 Tikanga。 在端口8080和nginx-1.0.14-1.el5.ngx 80上運行的兩個站點。我的意思是我有兩個目錄鏈接到/ var / www / html / site1和/ var / www / html / site2。 兩者都在php 5。

對於那些管理Red Hat網站的人,這對我有用

  1. 編輯http.conf並更改為Listen 8080
  2. 按照站點說明相應地修改nginx.conf。
  3. 修改虛擬主機文件/etc/httpd/conf.d/httpd-vhosts.conf或其他文件,只要它可以被http.conf include指令包含,如下所示:

$ NameVirtualHost *:8080

<VirtualHost *:8080>
    ServerAdmin me@mydomain.com
    ServerName localhost
    DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *:8080>
    ServerAdmin me@mydomain.com
    ServerName site1
    DocumentRoot /var/www/html/site1
</VirtualHost>

<VirtualHost *:8080>
    ServerAdmin sleepy@nightmare.com
    ServerName site2
    DocumentRoot /var/www/html/site2
</VirtualHost>`

/etc/nginx/nginx.conf-此文件頂部的修訂:

..... $worker_rlimit_nofile 20480; ....

    gzip_buffers 32 8k;
    gzip_comp_level   6;
    gzip_http_version 1.0;
    gzip_min_length   1;

#include /etc/nginx/conf.d/*.conf行已被注釋,因為這對我來說是無用的。 其余所有代碼均未更改,但我的IP服務器名 (在本例中為主機名 )和root指令與/ usr / share / nginx / html相同,這與虛擬conf文件/ var /中的不同。 www / html等/。 我的猜測是,作為前端的nginx不知道(甚至不應該)要提供Web文件的位置只是Apache。

當我轉到任何瀏覽器並鍵入:

ip顯示nginx默認頁面,所以我想它正在監聽80端口; ip / site1顯示site1 ip / site2顯示site2

除80或8080以外的任何其他端口都顯示連接錯誤。

問候。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM