Servers

How to Find Apache Error Log Path and Fix Issues

If your Apache server is not loading a webpage at all or giving an error, you’ll have to troubleshoot it. As always, first, try restarting the service and rebooting the machine. If it still fails, use the steps below to find the cause of the issue.

How to Find the Error Log Path

Run these commands in order to diagnose and fix Apache configuration issues. It’s assumed you have root privileges if you don’t, add sudo at the front. Instead of httpd you may also use apachectl which is a wrapper command around httpd.

First, test if there are issues with the configuration.

httpd -t

If you see any issues there, fix them first.

If not, then check your server error and custom logs. You can use httpd to find your error log locations.

httpd -D DUMP_INCLUDES

Then for each of the config files, find where the log files are located.

cat /usr/local/etc/httpd/httpd.conf | grep -E "ErrorLog|CustomLog"

If the above fails, try to locate the file with the locate command.

locate error_log

Read the Last Log Messages

Note the log file paths mentioned in the result. (Ignore the commented lines with #. Most of the errors will be written to error_log or access_log files. You can read the log, or use tail command to read the last lines.

tail /usr/local/var/log/httpd/error_log

You can increase the output lines with -n flag. For example, output last 50 lines.

tail -n 50 /usr/local/var/log/httpd/error_log

Other Possible Causes for Apache Server Restart Failures

Apache might sometimes leave a corrupt Process ID file, which might cause it to fail. If that happens, you may have to manually delete the file.

apachectl stop
rm /usr/local/var/run/httpd/httpd.pid
apachectl start

Or use all 3 commands in one line.

apachectl stop && rm /usr/local/var/run/httpd/httpd.pid && apachectl start

The pid file is genrally located in your httpd folder. If it’s a custom path, it will be listed on your httpd.conf file as a `PidFile variable.

Example (in httpd.conf)

PidFile /yourpathto/httpd.pid

MacOS · Technical · Today I Learned

Terminal Commands to Improve Productivity on Mac

Open any IntelliJ Idea editor from current folder. (Change PhpStorm to your editro’s name)

open -a PhpStorm ./

GIT – Reset uncommitted changes and files

git reset --hard && git clean -fd

Sublime Text – Create a CLI launcher

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Save Aliases

If you don’t want to remember these, you can add these to your ~/.bashrc or ~/.zshrc file.

# edit hosts file
alias edithosts='subl /etc/hosts'

# reset git folder
alias nah='git reset --hard && git clean -fd'

# open current folder in idea editor
alias storm='open -a PhpStorm .'

# clear DNS history
alias cleardns='sudo killall -HUP mDNSResponder'

# NPM install
alias ni='npm install'

After you update ~/.bashrc or ~/.zshrc, run the applicable command in terminal to load the changes.

source ~/.bashrc
// OR
source ~/.zshrc
MacOS · Today I Learned

Monosnap for Mac won’t Start? Here’s How to Fix

Monosnap is a great tool to take screenshots and annotate for Mac and Windows. With MacOS updates, sometimes it may not start. You can try reinstalling it, but it may not solve the problem.

Then you need to try removing all files created from it.

Open Terminal in Mac, and run these commands.

rm -rf ~/Library/Application\ Scripts/com.monosnap.monosnap
rm -rf ~/Library/Containers/com.monosnap.monosnap
rm -rf ~/Library/Application\ Scripts/com.monosnap.MonosnapLauncher

If you need to see if any crash reports were generated, run this.

ls ~/Library/Application\ Support/CrashReporter/Monosnap_*.plist

To delete the crash reports,

rm ~/Library/Application\ Support/CrashReporter/Monosnap_*.plist

After that, reinstall Monosnap, and the icon should showup in your menubar.

MacOS · Technical

New Terminal Setup Steps for MacOS

Here are the shortcuts and Terminal setup commands I used with MacOS.

Create a command to open Sublime from CLI.

sudo mkdir /usr/local/bin

sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

Edit the `~/.bash_profile` file, and include the following.

alias edithosts='subl /etc/hosts'

Update the `/etc/hosts` file to block unwanted sites. Use this example hosts file.

Uncategorised

How to Delegate for Results

Delegation is essential for faster growth and to make the most of your time. Often, delegation has been made unnecessarily complicated than it should be.

People don’t like to delegate stuff, because they believe “if it should be done right, I need to do it”. This is often a result of poor delegation skills combined with the wrong person assigned to the task.

Here are the steps you should follow to delegate effectively.

1. Eliminate:

Before you delegate, see if your task needs to be done at all. If the end result you’re after is not going to change anything, or if it’s going to improve a vanity metric, just ignore the task. Delegating a worthless task to someone else doesn’t make it more worthy.

2. Pick the Person:

Have a baseline criteria on how you select people for tasks. When there are multiple candidates, often you’ll be better off picking the person who does satisfactory work faster, rather than who does perfect work unreliably.

3. Define Clearly:

Clearly define the task on how it should be done. Understand that you already have a lot of background information about the task in your head, which the other person doesn’t have access to. So you have to put the task, in writing, because if you just say it, people can forget. Also having written instructions is good for the other person to refer if they get lost.

Here are some points you should cover.

  1. What’s the end outcome you’re after.
  2. What steps (if any) that MUST be followed.
  3. What should NOT be done.
  4. When you expect a response and how
  5. When you expect the task (or milestones) to be completed
  6. How the task and milestones to be delivered.
  7. What to do when there are questions about the task.
  8. How and when you expect to be kept updated.
  9. Give diagrams, designs, and other visual elements to ensure the task is properly understood by both parties.

4. Give Authority:

If you need something to be done, you need to give that person authority and access to all the required information. Don’t let them come back to you seeking parts of information, because that will just delay the process.

The level of authority can be:

Level 1: Inform – Just get the information and do the work

Level 2: Initiate – Progress and do the task within the given boundaries.

Level 3: Act – Do the task by any means and any costs. At this level, the person will have the full authority to get the task done, at any means, and at any cost – which means they’ll pay expenses out of pocket and will expect you to reimburse later.

5. Supervise at Checkpoints:

After a task is delegated, you must supervise it at set intervals.

In the beginning, you must supervise at regular intervals to ensure the task is on the right track after you’ve verified it, you can lengthen the checkpoint intervals.

Follow a Fibonacci Sequence to make this process easier. 0, 1, 1, 2, 3, 5, 8….

Example:

Follow up on Days 1, 1, 2, 3, 5, 8, 13, 21

However, if you see a task going off the rails at some point, then you have to stop and start the sequence from that point again.

6. Debrief:

After a task is done, hold a debrief session to see what worked and what didn’t. Get the learnings, and improve the system again, to prevent any issues which may have happened.