Tag Archives: apache

How to troubleshoot Mountain Lion’s Apache

After I install Mac OS X Mountain Lion, it seems like my Apache server can no longer start successfully:

bash-3.2# sudo tail /private/var/log/apache2/error_log
[Thu Aug 02 09:36:46 2012] [notice] caught SIGTERM, shutting down
[Thu Aug 02 09:37:57 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using kahwee-mba.local for ServerName
[Thu Aug 02 09:37:57 2012] [notice] Digest: generating secret for digest authentication ...
[Thu Aug 02 09:37:57 2012] [notice] Digest: done
[Thu Aug 02 09:37:57 2012] [notice] Apache/2.2.22 (Unix) DAV/2 mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Aug 02 09:46:17 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Thu Aug 02 09:54:19 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/r, referer: http://home.internal.kw.sg/
[Thu Aug 02 09:54:19 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Thu Aug 02 09:54:31 2012] [notice] caught SIGTERM, shutting down

To find out why, run apachectl -t:

bash-3.2# sudo apachectl -t
httpd: Syntax error on line 106 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_dav_fs.so into server: dlopen(/usr/libexec/apache2/mod_dav_fs.so, 10): Symbol not found: _dav_add_response\n Referenced from: /usr/libexec/apache2/mod_dav_fs.so\n Expected in: flat namespace\n in /usr/libexec/apache2/mod_dav_fs.so

Seems like it is caused by my disabling of mod_dav. mod_dav_fs acts as a support module for mod_dav and provides access to resources located in the server’s file system.

So I go to line 106 of /private/etc/apache2/httpd.conf and I comment out that line too.

sudo nano /private/etc/apache2/httpd.conf

Try to run the syntax check of Apache configuration again:

bash-3.2# sudo apachectl -t
Syntax OK
bash-3.2# 

That seems to be working, now we start Apache:

sudo apachectl start

Useful apachectl commands include:

  • apachectl start
  • apachectl stop
  • apachectl restart
  • apachectl -t

Hope it helps!

Tools of the trade

Every web developer uses his/her set of preferred tools. Here’s mine:

  • Text editor: SublimeText 2, because it loads fast and I swear by its open by file name feature
  • Computer: MacBook Air 13″, a decent screen size with good portability. I like working at cafés and this gadget fits my lifestyle.
  • Browser: Chrome 18 or 19. I lost track of Chrome’s version, comes with Chrome is the excellent debugger I cannot live without.
  • CSS generator: Less, because Less can be compiled by JavaScript on the client side. It’s easy to get started developing.
  • Database engine: MySQL InnoDB.
  • Database browser: Sequel Pro, never found a replacement for this. I’ve been using this for 3 years, by far the best.
  • Revision control: Git or SVN. My vote is to Git but my company is still on SVN.
  • Image editor: Photoshop. Embarrassingly I am one of those that will just launch Photoshop to make PNGs with alpha-transparency. There are probably better tools out there but I can’t get used to them.
  • Programming languages: PHP for web development. JavaScript or Ruby on scripting automation. I still use Expect for a bunch of server-side tasks, I cannot move away from that still.
  • Web server: Apache for development. It’s all because of PHP’s xdebug. My colleagues use .htaccess often too. I use nginx for production usually.
  • Load profiling: Seige, it’s simple and reliable.

Other tools include:

  • LiveReload 2 has been extremely convenient and it has been part of my workflow for months. I never looked back.
  • Bash alias lets me quickly navigate through the trenches of my messy directories. I also use it to pull for Git quickly.

How to use sendmail in XAMPP for Windows using AOL Mail

The easiest way to start developing in PHP is to get XAMPP, the whole package can even be placed in a flash drive. Using the free AOL Mail account also allows you to sign in to the SMTP server without TLS which allows XAMPP sendmail to work.

0. Objective

To get your PHP scripts to send an email out. This guide assumes you have XAMPP or XAMPP Lite. My environment is Windows Vista. (I use XAMPP Lite by the way.)

My XAMPP is placed in C:\xampplite\, so your configuration may be a little different. The files to be modified are sendmail.ini and php.ini. Continue reading “How to use sendmail in XAMPP for Windows using AOL Mail” »

Bye Apache, Hi Lighty

As planned, Apache is no more. Say hi to Lighty

Lighttpd logo fly light

Made a few silly mistakes along the way and almost accidentally deleted my folder of pictures even. Things got a little more responsive. I haven’t used any caching solutions for WordPress. Caching is going to be tough work.

I just let PHP CGI spawn happily:

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
2655 www-data  16   0 99816  31m 3804 S    0 12.4   0:22.67 php-cgi
2651 www-data  16   0 96060  29m 3308 S    0 11.6   0:04.91 php-cgi
2656 www-data  16   0 93976  26m 3968 S    0 10.2   0:24.59 php-cgi
2654 www-data  16   0 94008  26m 3856 S    0 10.2   0:24.88 php-cgi
2653 www-data  16   0 91612  25m 3200 S    0  9.8   0:03.52 php-cgi
2657 www-data  16   0 89840  22m 3784 S    0  8.7   0:24.06 php-cgi
2652 www-data  16   0 89580  22m 3980 S    0  8.6   0:04.27 php-cgi
2650 www-data  16   0 86716  20m 3196 S    0  8.0   0:03.94 php-cgi
2313 mysql     15   0  139m  17m 4368 S    0  6.7   0:19.83 mysqld
2649 www-data  23   0 71676 6232 3708 S    0  2.4   0:00.01 php-cgi
2647 www-data  23   0 71676 6224 3708 S    0  2.4   0:00.02 php-cgi
2672 root      15   0 53468 2696 2136 S    0  1.0   0:00.00 sshd
2645 www-data  15   0 55084 2628  892 S    0  1.0   0:00.22 lighttpd
2433 root      15   0 36676 2124 1676 S    0  0.8   0:00.00 master

Lighttpd don’t exactly take up a lot of resources too.

Tonight I’ll fix the server

It’s been requiring almost a daily restart. I think it’s probably MySQL or Apache’s fault. Or perhaps it’s just my fault for being a miser not wanting to pay for more. Either way, I’m going to fix it. So far, I’m done with the virtual hosts. Lighttpd isn’t as hard as I thought. PHP is working fine already. I’m still in the midst of testing if WordPress works. Once I’m done with that, it’s “sudo apt-get remove apache2″.