Skip to main content

Create security on your web server

Specification
Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch

Step to create:

1. create file .htaccess into the folder you need to protect.
Example:

AuthType Basic
AuthUserFile /var/www/mysite/.htpasswd
AuthName "Authorization Required"
AuthGroupFile /dev/null
Require valid-user
RewriteEngine on

AuthType Basic
AuthUserFile /var/www/mysite/.htpasswd
AuthGroupFile /dev/null
Require user [username]
RewriteEngine on

2. create file .htpasswd

htpasswd -cm /var/www/mysite/.htpasswd

The -c will initially create the file. The -m will md5 encrypt the passwords for additional security. The htpasswd command will prompt you for a password.

Be careful not to use the -c option when adding additional users as this will recreate the file and overwrite previous entries.

Troubleshoot
1. If there is nothing coming up when you access web, make sure that
1.1 Enable use of apache htaccess file => EnablingUseOfApacheHtaccessFiles
1.2 Check in error.log - you might see that server cannot located the .htpasswd path

2. If you can’t access your stuff and the dialog keeps popping up, check that you entered the username and password correctly. If it still doesn’t work, check the path to your .htpasswd and make sure the path specified in the AuthUserFile directive is correct. Also make sure that both the .htpasswd and .htaccess files are readable by the web server user chmod 644 should do the trick!

3. If you have done from item 2 and it still doesn't work, check in the error.log again. If you got access to / failed, reason: require directives present and no Authoritative handler, please make sure that apache has loaded and enabled the authz_user.load module
etc/apache2/mods-enabled>>ln -s /etc/apache2/mods-available/autz_user.load
>>usr/sbin/a2enmod authz_user

Moreover, you correctly typed AuthType as "Basic" in .htaccess
Make sure that .htaccess has written with textedit in the normal format.

More Information:
1. http://ubuntu-tutorials.com/2007/10/06/limiting-access-to-websitesdirectories-with-htaccess/
2. http://httpd.apache.org/docs/1.3/howto/auth.html

Comments

Popular posts from this blog

Book of Answer Privacy Policy

Privacy Policy Privacy Policy Jaa Yoo built the Book of Answer app as a Free app. This SERVICE is provided by Jaa Yoo at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. The terms used in this Privacy Policy...

Conjunctive Adverbs

Conjunctive Adverbs คือคำเชื่อมประโยคเข้าด้วยกัน 1. Addition  เสริมกัน Moreover/ Besides/ Furthermore/ Also/ In addition He is good at sport; moreover, he is good at cooking. 2. Contrast ขัดแย้ง อย่างไรก็ตาม However/ Nevertheless/ Nontheless/ / Still  + ประโยค The hotel is costly; nonetheless, the service is not impressive. ในทางกลับกัน In contrast/ On the contrary/ Conversely/ On the other hand + ประโยค ถึงแม้ว่า Although, Though, Even though + ประโยค ทั้งๆที่ Despite/ In spite of  + คำนาม 3. Alternative ทางเลือก Otherwise/ Or else You'll have to go now, otherwise you'll miss your bus. 4. Comparison เปรียบเทียบ Likewise/ Similarly/ In the same way I drink 8 glasses of water per day; my kids, likewise, do the same. 5. Illustrate ตัวอย่าง For example/ For instance + ประโยค such as/ namely + คำนาม There are many good hotels in town; for example, ABC Grand, FF Resort, Long Beach. 6. Resu...

การใช้ Both, Either and Neither นำหน้าคำนาม

Both ใช้กับคำนามพหูพจน์ Both + of + คำนามพหูพจน์ Both ไม่สามารถตามด้วยคำนามเอกพจน์ได้ Both children  were born in Italy. Both the children  were born in Italy. Both of the children  were born in Italy. Both my parents  have fair hair. Both of my parents  have fair hair. Both of us  like skiing. I told  both of them  to calm down. Either ความหมายเชิงบวก อ้างถึงคำนาม 1 คำ จาก 2 คำ ตามด้วยเอกพจน์ I can stay at  either hotel . Either day  is fine for me. There are two chairs here. You can take  either of them . Either of you  can come. Either of the hotels  will be fine. I can eat  either of the salads . Note   Either...or  เป็นคำเชื่อม ไม่ใช่คำนำหน้านาม Neither ความหมายเชิงลบ อ้างถึงคำนาม 1 คำ จาก 2 คำ ตามด้วยเอกพจน์ ถ้าเป็น Neither + of + คำนามพหูพจน์ Neither chair  is any good. Neither brother  came. Which bag do you want?  Neither of them . Neither ...