ensjtrans
By:
ensjtrans

.htaccess crashes my wordpress website

August 8, 2016 1.7k views
DigitalOcean One-Click Install Apps WordPress Ubuntu

Ok, I've struggled with this problem for several days now, and I don't know how to fix it. Apparently I need to create an .htaccess file in order to allow my users to start accessing the posts and pages in my wordpress website, but adding an .htaccess in /var/www/seonbinovels.com/public_html just crashes the website. No error 500 or anything. Straight up crashes the website.

Here's the code that I put into htaccess, seemed pretty ok to me...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

But the server just crashes. I've tried to see what was wrong by typing in apache2 -S in the console, but all I got was:

Apache error: Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

I don't even know what that means... In any case, I checked that mod rewrite was indeed on, and I've also allowed overrides in 000-default.conf. And yet my site still crashes. Does anyone know how I can fix this..?

P.S. I've checked the apache2 error logs, and found hundreds of lines that said PHP warnings. I don't know what that means or how I should fix it, but maybe that's related to all this?

5 Answers
Elizine August 8, 2016
Accepted Answer

It might happen due to the W3TC Cache plugin as it modifies your .htaccess file to include all that info. You will need to remove this plugin and then use the above code of .htaccess.

Hi,

can you display a part of apache log from /var/log/apache2? Do you have enough permissions on apache config for your sites? Try creating /var/log/apache/mutex writable directory and restart apache (service apache2 restart).

Kind regards,
Milan Bozic.

Hello, thank you for such a quick answer, @milanbozic

I've tried creating a mutex directory in both /var/log/apache2 and /var/log/apache, but I not nothing from either of them.

Also, here is a part of the apache error log.

[Mon Aug 08 00:06:39.102129 2016] [:error] [pid 25184] [client 114.79.53.166:46801] PHP Warning:  fopen(/var/www/seonbinovels.com/public_html/wp-content/plugins/bwp-minify/cache/minify_woocommercelayout,woocommerce,style,style,bootstrap,fontawes_387a8dcdea67a42bcdec5a634e8d6454): failed to open stream: No such file or directory in /var/www/seonbinovels.com/public_html/wp-content/plugins/bwp-minify/min/lib/Minify/Cache/File.php on line 100, referer: http://seonbinovels.com/
[Mon Aug 08 00:06:39.102153 2016] [:error] [pid 25184] [client 114.79.53.166:46801] PHP Warning:  flock() expects parameter 1 to be resource, boolean given in /var/www/seonbinovels.com/public_html/wp-content/plugins/bwp-minify/min/lib/Minify/Cache/File.php on line 101, referer: http://seonbinovels.com/
[Mon Aug 08 00:06:39.102159 2016] [:error] [pid 25184] [client 114.79.53.166:46801] PHP Warning:  stream_get_contents() expects parameter 1 to be resource, boolean given in /var/www/seonbinovels.com/public_html/wp-content/plugins/bwp-minify/min/lib/Minify/Cache/File.php on line 102, referer: http://seonbinovels.com/
[Mon Aug 08 00:06:39.102164 2016] [:error] [pid 25184] [client 114.79.53.166:46801] PHP Warning:  flock() expects parameter 1 to be resource, boolean given in /var/www/seonbinovels.com/public_html/wp-content/plugins/bwp-minify/min/lib/Minify/Cache/File.php on line 103, referer: http://seonbinovels.com/

Judging by that log you have problem with Better WP Minify plugin, that plugin is outdated anyway. Disable it and give that code in .htaccess a try.

It worked! Thank you so much!

  • I was glad to help. By the way I now noticed that you get high volume of traffic on your site, 3 things to pin point: 1) minimum 30% of your visitors are just bots which eats bandwidth and slow your server down, you need to block them (and robots.txt and .htaccess block of bad bots is not so effective and also can slow server, you need to stop them on server level, that's easy if you use nginx or varnish in front) ; 2) You should not really use apache for that, nginx handle that better; 3) You should use caching system (I recommend Varnish). Kind regards.

Have another answer? Share your knowledge.