2014-02-20 78 views
7

我在ubuntu 13.10配置Zend應用程序(ZF2)。按照下面的步驟:zf2安裝在Ubuntu 13.10與Apache虛擬主機

  1. 將代碼/var/www/與名zfapp

虛擬主機配置:

<VirtualHost *:80> 
    ServerName zfapp.com DocumentRoot /var/www/zfapp/ 

    <Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
    </Directory> 

    ErrorLog /var/log/apache2/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 
    CustomLog /var/log/apache2/access.log combined 

</VirtualHost> 
  1. 爲它創造的虛擬主機在/etc/hosts

    127.0 .0.1 zfapp.com在/etc/apache2/sites-available/zfapp.cof

  2. sudo a2enmod rewrite

  3. sudo a2ensite zfapp.conf

  4. sudo service apache2 restart

然而,當我瀏覽到該網站(zfapp.com/api/user/auth

  • 添加文件;它給出了以下錯誤:

    Not Found The requested Url /api/user/auth was not found on this server

    我有一個JavaScript MVC項目,其中我使用PHP作爲服務器端語言。

    下面是該項目的目錄結構:

    PROJECTDIR javascriptMVC文件夾 - >模型/控制器jsfiles API文件夾 - > Zend的項目

    我做了一個符號鏈接API指向api/publicjavascriptMVC目錄,我使用AJAX調用PHP服務器。像/api/user/auth。相同的結構在舊的Ubuntu機器上工作。

    我認爲這與Apache的配置有關;或者也許我必須設置任何別名?

  • +0

    1 - 什麼代碼... – Sam

    +1

    你可以只打'zfapp.com'嗎? – Bilal

    +0

    @Bilal是的,我可以擊中 –

    回答

    10

    感謝所有,

    我已經找到了問題。

    在apache 2.4.6和ubuntu 13.10中,我們需要更新apache2。由 https://askubuntu.com/questions/423514/how-to-enable-mod-rewrite-for-virtual-host

    :CONF 變化

    <Directory /var/www/> 
        Options Indexes FollowSymLinks 
        AllowOverride None 
        Require all granted 
    </Directory> 
    

    <Directory /var/www/> 
        Options Indexes FollowSymLinks 
        AllowOverride All 
        Require all granted 
    </Directory> 
    

    ,並創建虛擬主機的文件這樣的事情,

    <VirtualHost zfapp.com:80> 
        ServerName zfapp.com 
    
        DocumentRoot /var/www/zfapp/index 
    
        <Directory /var/www/zfapp/index> 
           Options Indexes FollowSymLinks 
           AllowOverride All 
           Require all granted 
         </Directory> 
    
        ErrorLog /var/log/apache2/error.log 
        CustomLog /var/log/apache2/access.log combined 
    </VirtualHost> 
    

    我發現從溶液方式,謝謝@Bilal,@ jmleroux

    +0

    如果你仍然有這個配置有500個錯誤,像我一樣,嘗試啓用模塊重寫:sudo a2enmod rewrite –

    2

    沒有代碼,這是很難診斷...

    也許URL的問題改寫:

    你啓用了mod_rewrite?

    您是否設置了AllowOverride All

    +0

    YES,其啓用使用(須藤a2enmod重寫) –

    +0

    也許這是新的Apache:13.10自帶apache的2.4。你需要'要求所有授予' – jmleroux

    +2

    「沒有代碼,很難診斷」那麼不要;這不是一個答案;而是兩個應該是評論的問題。 – AlexP