2012-09-06 142 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