运行Apache / Linux的AWS EC2中的密码保护目录 [英] Password protect directory in AWS EC2 running Apache/Linux

查看:104
本文介绍了运行Apache / Linux的AWS EC2中的密码保护目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我有一个带有Apache的AWS EC2实例。这是一台Linux服务器。我想用密码保护一个目录。我正在关注以下答案: https://stackoverflow.com/a/18178857/989722

As the title says, I have an AWS EC2 instance with Apache. It's a Linux server. I want to password protect one directory. I was following this answer: https://stackoverflow.com/a/18178857/989722

htaccess:

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /var/www/admin/.htpasswd
Require valid-user

创建了适当的.htpasswd文件,但想知道是否还有其他步骤。

Created a proper .htpasswd file, but wondering if there's another step.

但是,它不起作用(即,目录不受保护)。我重新启动了服务器,但没有帮助。想知道是否需要更改配置文件中的内容。

However, it's not working (i.e., directory isn't protected). I restarted my server and that didn't help. Wondering if I need to change something in my config file.

如果我使用终端<$ c $查看放置.htaccess文件的目录的内容, c> ls ,则看不到.htaccess文件。我使用SFTP上传了它,并使用我的FTP应用程序看到了它,但实际上可能不存在。我的.htpasswd文件也是如此。

If I look at the contents of the directory where I placed my .htaccess file, using terminal ls, the .htaccess file isn't visible. I uploaded it using SFTP and see it using my FTP application, but maybe it's not actually there. Same thing for my .htpasswd file.

推荐答案

愚蠢的错误。

需要将其添加到我的服务器配置文件中:

Needed to add this to my server config file:

<Directory /var/www/html/MYPROTECTEDDIRECTORY>
AllowOverride All     
</Directory>

这篇关于运行Apache / Linux的AWS EC2中的密码保护目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆