By collinmoore
Trying to lock down www/html/ using .htaccess on a LAMP 14.04 deployment, and having a tough time. Documentation is all over the place without a clear answer.
Tried updating 000-default.conf Tried updating .htaccess to point to .htpasswd Did lots of restarts of apache2
Nothing worked.
Suggestions?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
In order to enable an .htaccess file, there are a few steps you need to take. In /etc/apache2/sites-available/000-default.conf you need to add:
<pre> <Directory “/var/www/html”> AllowOverride All </Directory> </pre>
Then create the file /var/www/html/.htaccess with the contents:
<pre> AuthUserFile /etc/htaccess/.htpasswd AuthName “Authorization Required” AuthType Basic require valid-user </pre>
Then run:
<pre> sudo mkdir /etc/htaccess/ sudo htpasswd -c /etc/htaccess/.htpasswd user1 </pre>
And finally, restart apache:
<pre> sudo service apache2 restart </pre>
Well…
In this tutorial [https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04 ] we learn to create a user and give you root privileges ok. Good. I did it correctly and now looked at the file and is equal to the tutorial.
I’m trying to use this option suggested by @astarr and the answer I have is can not create directory ‘/etc/htaccess/’: Permission denied
Can I get using root?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.