更新:

更新:

我正在 aws ec2 上的 ubuntu 14.04 伺服器上使用 apache 2.4 設定 joomla 3.x 網站。僅此一點就可以使 url 重寫正常工作。在為 nginx 釋放連接埠 80 之前,我已經清除了所有 apache 問題。

我對 nginx 沒有什麼特別的問題,儘管我剛開始使用它,而且這是它的第三次部署。我用基本的東西就可以了。

我按照教程如何鍛造。設定完之後。我意識到只有索引頁面正確加載,所有其他頁面都需要index.php?在網域和可愛的網址之間,例如

 stage.domain.com/bla/bla # doesn't work
 stage.domain.com/index.php?/bla/bla/ # works

我見過很多人遇到這個問題,但他們要么直接在 nginx 中託管 joomla,要么直接在 apache 中託管。 apache 託管 joomla 前面接近 nginx 的情況的解決方案對我不起作用,可能我沒有正確的 nginx 理解,所以請耐心等待。以下是配置:

#/etc/nginx/site-enabled/stage.domain.com.vhost
server {
   listen 80;
   server_name www.stage.domain.com stage.domain.com;
   
   root /var/www/html/vhosts/stage.domain.com/htdocs_april;

   index index.php index.html;

   location / {
            try_files $uri @proxy;

   }

   location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
        expires      5d;
   }

   location @proxy {
            proxy_pass_header Server;
            proxy_pass http://127.0.0.1:8000;
            include /etc/nginx/proxy_params;
   }

   location ~* \.php$ {
            proxy_pass http://127.0.0.1:8000;
            include /etc/nginx/proxy_params;
   }

下面是 proxy_params (雖然這並沒有透露真實的 IP,但在我的多次試驗之一中我可以得到它。我將不得不在主要問題之後解決它)

   #/etc/nginx/proxy_params
   proxy_set_header Host $http_host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;

以下是 apache2 連接埠配置

   #/etc/apache2/ports.conf
   NameVirtualHost *:8000
   Listen 8000

   #Listen 80

   <IfModule ssl_module>
    Listen 443
   </IfModule>

   <IfModule mod_gnutls.c>
    Listen 443
   </IfModule>

下面是apache虛擬主機

<virtualhost *:8000>
    # Admin email, Server Name (domain name) and any aliases
    ServerAdmin [email protected]
    ServerName stage.domain.com

    #RewriteEngine On
    # Index file and Document Root (where the public files are located)
    DirectoryIndex index.php index.html
    DocumentRoot /var/www/html/vhosts/stage.domain.com/htdocs_april/
    <Directory /var/www/html/vhosts/stage.domain.com/htdocs_april/>
       Options Indexes FollowSymLinks
       AllowOverride All
       Require all granted
    </Directory>

   # php_flag log_errors on
    #php_flag display_errors off
    #php_value error_reporting 6143
    LogLevel warn
    ErrorLog  ${APACHE_LOG_DIR}/domain_error.log
    CustomLog ${APACHE_LOG_DIR}/domain_access.log combined
 </virtualhost>

如果有人能指出錯誤配置,我將不勝感激。就像之前提到的讓 apache 單獨使用我沒有 url 重寫問題。謝謝。

更新:

apache2錯誤日誌中的錯誤與nginx中的404無關,並且在使用index.php?/時具有相同的輸出:

 #Info Level
 [Fri Feb 27 22:51:47.862668 2015] [:error] [pid 12511] [client 127.0.0.1:58301] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/html/vhosts/stage.domain.com/htdocs_april/templates/stage2013/functions/tpl-init.php on line 313

 #Debug Level
 [Fri Feb 27 22:51:47.977454 2015] [deflate:debug] [pid 12511] mod_deflate.c(849): [client 127.0.0.1:58301] AH01384: Zlib: Compressed 49347 to 11157 : URL /index.php
 [Fri Feb 27 22:51:47.977925 2015] [headers:debug] [pid 12511] mod_headers.c(845): AH01502: headers: ap_headers_output_filter()
 [Fri Feb 27 22:51:48.606561 2015] [authz_core:debug] [pid 12512] mod_authz_core.c(802):   [client 127.0.0.1:58304] AH01626: authorization result of Require all granted: granted, referer: http://stage.domain.com/
 [Fri Feb 27 22:51:48.606593 2015] [authz_core:debug] [pid 12512] mod_authz_core.c(802): [client 127.0.0.1:58304] AH01626: authorization result of <RequireAny>: granted, referer: http://stage.domain.com/
 [Fri Feb 27 22:51:48.607274 2015] [deflate:debug] [pid 12512] mod_deflate.c(849): [client 127.0.0.1:58304] AH01384: Zlib: Compressed 1537 to 544 : URL /templates/stage2013/html/mod_fpss/stage5/css/template.css.php, referer: http://stage.domain.com/
 [Fri Feb 27 22:51:48.607293 2015] [headers:debug] [pid 12512] mod_headers.c(845): AH01502: headers: ap_headers_output_filter()

相關內容