Category Archives: Apache

Cloudflare – ban country with .htaccess

One of my clients asked me to BAN an specific country to one of his sites.
Since we have Cloudflare, this is how I made it…

On .htaccess I’v simply added the following lines – on the top of .htaccess -.

SetEnvIf CF-IPCountry IN BuzzOff=1
SetEnvIf CF-IPCountry PT BuzzOff=1
Order allow,deny
Allow from all
Deny from env=BuzzOff

But remember!
Domain/subdomain must have Cloudflare active on DNS settings…

Negotiation: discovered file(s) matching request

 

AH00687: Negotiation: discovered file(s) matching request: /home/httpd/html/domain.com/public_html/login (None could be negotiated)., referer: http://www.domain.com/

Under the domain.com.conf I had

Options Indexes FollowSymLinks MultiViews

The solution is to remove MultiViews from it.

Options Indexes FollowSymLinks

 

Source: http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm

discourse – htpasswd protected

discour-apache-htpasswd

I have client who *needs* discourse under a subdomain that should be only accessed by users who have a valid username & password in a .htpasswd….
Since discourse doesn’t use Apache I had to implement Apache ProxyPass  to solve this ‘issue’…

This is how it looks…

<VirtualHost *:80>

 ServerName social.subdomain.com

 ProxyPreserveHost Off
 ProxyPass / http://192.241.XXX.XX/
 ErrorLog /data/logs/discourse_error.log

 <Location />
   AuthType Basic
   AuthName "Only for members"
   AuthBasicProvider file
   AuthUserFile "/path/to/.htpasswd"
   Require valid-user
 </Location>

</VirtualHost>

This might not be the best solution….. comments are appreciated! 🙂

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

This new server with Ubuntu 16.04 LTS cames with PHP 7.0.

The backup that I have from my client has some old WordPress blogs…

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

I need to downgrade PHP 7.0 to PHP 5.6, at least for now.

Before you procede with the tutorial on the following link, and if you are running a new Ubuntu 16 installation you might get upon the following error while following the tutorial.

root@sd-4XXXX:/home/httpd/html# sudo add-apt-repository ppa:ondrej/php
sudo: add-apt-repository: command not found

To install add-apt-repository you will need to run the following command

sudo apt-get install software-properties-common

Now the solution  How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04? [duplicate].

 

Apache / PHP – End of script output before headers

 

[Thu May 12 03:14:41.562083 2016] [core:error] [pid 25726] [client 68.71.XXX.XXX:44611] End of script output before headers: manage.php
[Thu May 12 03:14:41.697026 2016] [:error] [pid 26855] [client 84.91.XXX.XXX:60222] SoftException in Application.cpp:256: File “/home/rocker/public_html/system/manage.php” is writeable by group

I had to set the file to 755.

As seen on http://stackoverflow.com/questions/17583341/error-500-premature-end-of-script-headers

cannot read directory for multi:

While I was setting up a CGI directory I was getting the following error

[Tue May 03 01:22:11.274857 2016] [negotiation:error] [pid 2625] (13)Permission denied: [client 84.91.XXX.XXX:49530] AH00686: cannot read directory for multi: /var/www/domain.com/, referer: http://domain.com/

This solved me the issue….

ScriptAlias /cgi-bin/ /var/www/domain.com/cgi-bin/
 <Directory /var/www/domain.com/>
   AllowOverride None
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   Order allow,deny
   Allow from all
</Directory>

Invalid command ‘UserDir’, perhaps misspelled or defined by a module not included in the server configuration

 

root@71796:/home/# service apache2 restart
 * Restarting web server apache2 [fail]
 * The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 10 of /etc/apache2/sites-enabled/domain.com.conf:
Invalid command 'UserDir', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.

Solution?
Enable usedir.

sudo a2enmod userdir

Then restart apache 🙂