Here is a good tutorial how to do it.
Category Archives: Apache
.htaccess – two different .htpasswd files
Its easy!
* * * * * cat passwd1 passwd2 > combined_passwd
Lets then use this combined passwords file.
AuthUserFile /path/combined_passwd
SSL tutorials
Just bought a SSL certificate for one of my clients….
Here are some useful tutorial links.—
CSR Generation: Using OpenSSL (Apache w/mod_ssl, NGINX, OS X)
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/1/66/
Nginx CSR Generation using OpenSSL
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/801/0/nginx-csr-generation-using-openssl
Certificate Installation: Apache & mod_ssl
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/637/66/
Certificate Installation : NGINX
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/1091/0/certificate-installation–nginx
.htpasswd not working?
Spent almost 12h figuring out why a htaccess / htpasswd wasn’t working…
[Mon Apr 04 14:45:45.605734 2016] [authn_file:error] [pid 21193] (13)Permission denied: [client 84.91.XXX.XXX:62465] AH01620: Could not open password file: /home/rocker/public_html/control/data/.htpassw
That was it! File permissions!
apache – Error 414 URI Too Long

We need to increase LimitRequestLine @ apache2.conf.
500 Internal Server Error while uploading files
I was having a 500 Internal Server Error…
nginx logs were showing me the following
2016/03/17 12:09:32 [crit] 31488#0: *11192 open() "/var/lib/nginx/tmp/client_body/0000000005" failed (13: Permission denied), client: 84.91.XXX.XXX, server: host.com, request: "POST /trades_edit/edit_trade HTTP/1.1", host: "host.com", referrer: "https://host.com/trades_edit/125"
Solution?
chown -R www-data:www-data /var/lib/nginx
CloudFlare Apache Module – Ubuntu 14.04 LTS
If we have CloudFlare active on the domain/subdomain that is protected with IP *validation* we need to install libapache2-mod-cloudflare, so Apache can see the real visitor IP, other way it will see the CloudFlare IP, and we wont be able to access the sub/domain.
![]()
Step 1
echo 'deb http://pkg.cloudflare.com/ trusty main' | sudo tee /etc/apt/sources.list.d/cloudflare-main.list
Step 2
curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add -
Step 3
sudo apt-get update
Step 4
grep ^Package: /var/lib/apt/lists/pkg.cloudflare.com_dists_trusty_main_binary-amd64_Packages
Step 5
sudo apt-get install libapache2-mod-cloudflare
Step 6
sudo service apache2 restart

sudo: unable to resolve host
While I was trying to install Mcrypt PHP I got the following error sudo: unable to resolve host.
root@scw-db0acc:/home/webroot/my# sudo php5enmod mcrypt sudo: unable to resolve host scw-XXXX
I had to edit /etc/hosts and add the following entry to it:
127.0.0.1 scw-XXXX
Hooray!
Apache 2.4 – allow specific IP
Simple Apache 2.4 configuration to allow a specific IP address to access the sub/domain.
<VirtualHost *:80> ServerAdmin [email protected] ServerName admin.something.pt DocumentRoot /home/webroot/tools/public/ ErrorLog /home/webroot/tools/logs/error.log CustomLog /home/webroot/tools/logs/access.log combined <Directory /home/webroot/tools/public/> Options Indexes FollowSymLinks MultiViews AllowOverride All Require ip XXX.XXX.XXX.XXX </Directory> </VirtualHost>
Force www on a domain with apache
This is how!
Edit a .conf (in my case I have a redirects.conf) for this kind of redirects….
nano /etc/apache2/sites-enabled/redirects.conf
And add the following lines…
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
and naturally restart apache! 😉
service apache2 restart