Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
How do I get Apache .htpasswd to work in this case?

I have a website running on an AWS EC2 Amazon Linux 2 AMI with Apache and PHP/Laravel. It's a test site though and I want to password-protect the site via .htpasswd. Even after following several tutorials, I can't seem to get it working. It's worth noting that the site works perfectly fine without the .htpasswd configuration.

When I try to set it up and go to the site, it prompts me for the user name and password, but upon properly entering them, I get the following error:

enter image description here

To set up the .htpasswd file, I ran the following commands:

cd ~
htpasswd -c .htpasswd project-name # Then input a password when prompted to.
sudo chown ec2-user:apache .htpasswd
sudo chmod 777 .htpasswd

I then added the following to the .htaccess file in the public directory of the Laravel project:

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/ec2-user/.htpasswd
Require valid-user

And when I try to load the site, I get the above error. If I comment out the four lines in the .htaccess file, then it works fine, but I can't get it to work otherwise. I'm not sure what's going on, as the Apache config is fairly straightforward.

If it matters, I did add a virtual host config to Apache's httpd.conf file. It looks something like this:

<VirtualHost *:80>
    ServerName ip-address
    DocumentRoot /var/www/project-name/public
    <Directory /var/www/project-name>
        AllowOverride All
    </Directory>
</VirtualHost>

Also, I'm not sure if it matters, but because this is a test site, there's no domain name associated with it. It's only accessible via an IP address.

I've tried restarting the Apache service and anything else I can think of, but to no avail. Does anyone have any thoughts as to what I might be doing wrong? Thank you.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I was having trouble viewing the Apache error log, which is why it was so difficult for me to see what was going on, but after figuring out how to access the error log, I saw that there was a permissions issue. I moved the .htpasswd file in the ec2-user home directory to a different location and it instantly worked. Thanks.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda