I experienced a wierd bug: My post/page edit was gone during edits.

I could make new pages and posts. But I couldnt edit pages or posts. The main editor was gone. The only thing I saw was the Permalink textbox.

Right before that I remember I turned on like 5 different plugins that have to do with SEO and Google Analytics, and who knows how they could of messed something something up.

Well here is a tip to find out what or who the culprit is.

SSH into your box (hopefully you have ssh access)

Find out if you have apache2 (i have that) – in some distros its called httpd (but none the less its still apache2)

ps aux | egrep “httpd|apache”

Whatever process shows up, thats what you have

Now just watch the tail log by tailing its output. Its called following the tail. Its basically looking at new log enteries as they happen to a file. The tool is called tail. We will use the -f parameter for “following” the end of the file (and any writes that happen to it – like new log writes).

What file will we watch? The error log of course.

cd /var/log/apache2 

or

cd /var/log/httpd

ls -lisah

you might have access.log and error.log, maybe even access.log.1 and so forth. The recent ones are the ones without the numbers (when the logs get too old/big they get a number appended to them and a new log is written) The system always writes access information to access.log (by default) and error information (which is what we need) to error.log (by default). If your log files look different you will need to scope out your sites files and your apache.conf and httpd.conf files to see where log files are written to (Ill show you how to do that later)

First lets follow the error:

tail -f /var/log/apache2/error.log

tail -f /var/log/httpd/error.log

You can even monitor both access and error logs at the same time

tail -f /var/log/apache2/error.log /var/log/apache2/access.log

or using some bash skills:

tail -f /var/log/apache2/{error.log,access.log}

tail -f /var/log/httpd/{error.log,access.log}

Note: there is a program called tailf, that pretty much does exactly what tail -f does.

Anyhow, once you write the command of your choice and hit enter and start watching the access/error logs: I recommend holding enter until you get a blank terminal (or as much of blank screen as you can get before log information starts flowing in)

Note:  I recommend just watching the error.log if you have alot of page accesses to your page, or else the access.log will overwhelm your screen and you wont catch the error log when it scrolls across the screen.

Now its time to do the operation thats not working, go to edit a post or a page, and look at how the devil is not allowing the editor to show up.

At the same time look at the output of error.log (hopefully its an apache2 issue and it will tell you exactly what the problem was, like it did for me)

Here is what I got:

So I was instantly able to see that plugins/post-analytics is the culprit.

So I went to my plugins and turned off plugins/post-analytics. Went to edit a page and voila the editor is back (and no more error log information) I repeated with a post edit, and also got good news.

The end.

Like I promised earlier if your log files arent saved as normal you might need to enable them or see where else they could be being written to. Go to your apache folder

cd /etc/apache2

or

cd /etc/httpd

egrep -ir “ErrorLog|CustomLog” *

Note: I keep using egrep instead of grep because its easier to use the OR feature (which looks for more then one thing) using that | symbol you saw me use.  “ErrorLog|CustomLog” So I was looking for ErrorLog or CustomLog (meaning find me both – one or the other – and they dont have to both be on the same line). Also the -i means that its a case insenstive search so it would find things like ERRORlog or errorlog as well. The -r is a recursive search so it will look thru subfolders. The * at the end tells it to look thru everything here. You have to tell egrep what to look thru (either with piped in input, or a filename or many filenames which is what * gives it)

Here is my example output:

For me it tells me my logs go to

sites-available/default: ErrorLog ${APACHE_LOG_DIR}/error.log
sites-available/default: CustomLog ${APACHE_LOG_DIR}/access.log combined

Note the bold part sites-available/default is the part which configures where the logs go. You could have several files that do it, so you will need to find out which is the acting file. If your just running a default config you will just have sites-available/default or sites-available/default-ssl. Anyhow I dont recommend editing those files unless you know what your doing. Just use the output of the egrep commands to find out where the logs are.

well great now we know that the log files go to

${APACHE_LOG_DIR}/access.log and to ${APACHE_LOG_DIR}/error.log

But where is ${APACHE_LOG_DIR}. Lets do another egrep to find out

egrep -ir “${APACHE_LOG_DIR}” *

My output is

 

This tells me that the logs which go to ${APACHE_LOG_DIR}/access.log and ${APACHE_LOG_DIR}/error.log actually go to /var/log/apache2$SUFFIX/access.log and/var/log/apache2$SUFFIX/error.log

One more piece of the puzzle to find, what is this $SUFFIX variable.

Remember everything in bash that has a $ dollar sign around it is a variable, like so $VARIABLE. Variables also start with a $ dollar sign and have curly brackets around it like so ${VARIABLE}. But in bash/linux to set a variable you dont need the the dollar sign or the curly brackets, so when we look for what the variable is set to we dont need the $ or the ${}. Also variables in bash are case sensitive so $SUFFIX and $suffix would be different variables. But $SUFFIX and ${SUFFIX} are the same. The $ and ${} are just different ways to call upon the value the variable is holding on to.

This time i suppose SUFFIX is a common word and I only want to find SUFFIX. So my egrep wont have -i. That way it just looks for SUFFIX and not any variant of the casing.

So now we know the SUFFIX is either

SUFFIX=”-${APACHE_CONFDIR##/etc/apache2-}”

SUFFIX=

Since they are both in the same file, the last one called sticks. So SUFFIX= nothing, so $SUFFIX will bring about a null character(nothing not a space not a character)

This tells me that the logs which go to ${APACHE_LOG_DIR}/access.log and ${APACHE_LOG_DIR}/error.log actually go to /var/log/apache2$SUFFIX/access.log and/var/log/apache2$SUFFIX/error.log.

With knowing $SUFFIX I now know the final locations of the logs have to be:

/var/log/apache2/access.log and/var/log/apache2/error.log.

Leave a Reply

Your email address will not be published. Required fields are marked *