2012-09-06 153 views
17

我剛剛將我的博客從我的本地網絡服務器轉移到Amazon EC2免費Linux服務器,除了固定鏈接外,一切似乎都正在運行,我禁用並重新啓用了它們,並且它仍然中斷。Wordpress EC2上的固定鏈接

我試着運行腳本

sudo a2enmod rewrite 

但它說a2enmod:找不到命令同時登錄到我的服務器EC2用戶

任何幫助,將不勝感激!

感謝

回答

43

我只是有這個同樣的問題,假設您正在使用httpd,你將需要去/etc/httpd/conf,然後打開http.conf,運行sudo vi httpd.conf,然後將「AllowOverride」更改爲:

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

您可能還需要改變這裏AllowOverride All

# AllowOverride controls what directives may be placed in .htaccess files. 
# It can be "All", "None", or any combination of the keywords: 
# Options FileInfo AuthConfig Limit 
# 
    AllowOverride All 

然後,你需要通過運行apachectl -k restart重新啓動httpd的。請注意,您可能需要實際運行sudo apachectl -k restart

讓我知道是否有幫助。

+1

嘿卡爾,不能多謝你!尤其是'sudo apachecl -k restart'部分。無法找到其他來源,並感到非常沮喪...謝謝! –

+0

'apachectl -k restart'對我不起作用,但'sudo service httpd restart' did – jaressloo

+0

有一個朋友有類似的問題,而且她的配置稍有不同。她的wordpress安裝在'var/www/html /'中,並且在特定目錄的目錄塊中有一個'AllowOverride None'指令。 在這種情況下,您需要將'AllowOverride'指令設置爲該文件夾的目錄塊中的'All' - 我建議將它留給'None'作爲其他目錄塊使用wordpress。 – SierraKomodo

0

您的服務器可能沒有啓用AllowOverride指令。如果您的Apache httpd.config文件中的AllowOverride指令設置爲None,則完全忽略.htaccess文件。

在這種情況下,服務器甚至不會嘗試讀取文件系統中的.htaccess文件。當此指令設置爲全部時,那麼.htaccess文件中允許具有.htaccess上下文的任何指令。在httpd.config啓用AllowOverride指令的例子:

Options FollowSymLinks

AllowOverride All

這個鏈接也可能會有所幫助:http://codex.wordpress.org/Using_Permalinks

1

在AWS上我的文件是在一個稍微不同的位置:

sudo nano /etc/httpd/conf/httpd.conf 

兩個locaitons改變AllowOverride NoneAllowOverride Allsudo service httpd restart永久重定向重新啓動後的工作太棒了!

0

AllowOverride控制可以在.htaccess文件中放置哪些指令。 它可以是「全部」,「無」,或者關鍵字的任意組合: 選項的FileInfo AuthConfig極限

AllowOverride All 

當我設置我的服務器上,然後我得到了503內部服務器錯誤,任何ADVI請?

0

我不得不在一個以上的.conf文件中使用AllowOverride All和Options + FollowSymLinks(並且我在嘗試時也嘗試了a2enmod重寫)。但它是最後一個.conf文件,顯然是控制該目錄(我們使用的.iso導致幾個具有相同的目錄...並且我改變的第一個沒有效果)。但一旦他們都擁有這些設置,系統就開始工作。

1

基本視頻說明:Connecting to Your Linux Instance from Windows Using PuTTY

步驟1:打開PuTTY在AWS EC2控制檯登錄

第2步:輸入服務器地址

enter image description here

第3步:瀏覽驗證私鑰膩子

enter image description here

第4步:通過膩子登錄AWS(輸入「登錄姓名」,即您的AWS EC2實例名稱。對於上面的例子:EC2用戶)

步驟5:將目錄到/ etc/httpd的/ CONF($ cd /etc/httpd/conf

步驟6:執行sudo vi httpd.conf更新httpd.conf文件。 (在VI編輯器中打開httpd.conf文件)

更新後

<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory> 

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

而且

# AllowOverride controls what directives may be placed in .htaccess files. 
# It can be "All", "None", or any combination of the keywords: 
# Options FileInfo AuthConfig Limit 
# 
    AllowOverride None 

# AllowOverride controls what directives may be placed in .htaccess files. 
# It can be "All", "None", or any combination of the keywords: 
# Options FileInfo AuthConfig Limit 
# 

    AllowOverride All 

第7步:保存並退出VI編輯器。

要保存並從VI編輯按[Esc]鍵退出並鍵入:wq

步驟8:重啓Apache

類型sudo apachectl -k restart

最終截圖

enter image description here