After I install Mac OS X Mountain Lion, it seems like my Apache server can no longer start successfully:
[code lang=”bash”]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_responsen Referenced from: /usr/libexec/apache2/mod_dav_fs.son Expected in: flat namespacen 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.
[code lang=”bash”]sudo nano /private/etc/apache2/httpd.conf[/code]
Try to run the syntax check of Apache configuration again:
bash-3.2# sudo apachectl -t
That seems to be working, now we start Apache:
[code lang=”bash”]sudo apachectl start[/code]
Useful apachectl commands include:
- apachectl start
- apachectl stop
- apachectl restart
- apachectl -t
Hope it helps!
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.
- 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.
- 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.
This is more for my own reference. This is my development computer’s httpd-vhosts.conf. I don’t suppose anyone would find this useful: Continue reading My Apache Virtual Host file
Haven’t been tending to my blog recently. The Apache server was having some trouble and I didn’t notice. Learnt my lesson and now offload more static content to nginx server leaving Apache for mainly PHP content. My load average still spikes once in a while, I’ll be monitoring it a little more closely this week.
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.
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
As planned, Apache is no more. Say hi to Lighty
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[/code]
Lighttpd don’t exactly take up a lot of resources too.
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”.
This is what happens if you don’t clear your Apache logs:
[code lang=”bash”]jr ~/i.justrealized.com/log: ls -al
drwxr-s— 2 me www-data 4096 Aug 5 2008 .
drwxr-s— 8 me www-data 4096 Sep 9 14:58 ..
-rw-r–r– 1 root www-data 210250161 Feb 21 17:08 access.log
-rw-r–r– 1 root www-data 205822 Feb 21 15:49 error.log[/code]
That’s 210 MB of data I am least interested with. By the way I just realized delete the log actually lowers memory usage significantly.
Actually this probably works for all Linux distributions with Apache 2. Okay enabling mod_rewrite is really easy, you just have to use a2enmod (Apache 2 enable module):
[code lang=”bash”]sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart[/code]
To disable an Apache 2 module, you can run:
[code lang=”bash”]sudo a2dismod rewrite
sudo /etc/init.d/apache2 restart[/code]
That does the reverse.
With mod_rewrite enabled, you can use the .htaccess file.
By the way in your directory permissions, you must set AllowOverride to “all” like this:
Options Indexes FollowSymLinks MultiViews
allow from all
Hope it helps.
My environment is Ubuntu 8.1 Intrepid Ibex. I also written a guide on how to set up virtual hosts in Windows XP or Windows Vista.
Sometimes, we have multiple projects and we would like to access the Project 1’s website by typing ‘http://project1/’ in the browser address bar. And Project 2 may be at ‘http://project2/’. Virtual hosts are what you need for your development work. This guide requires you to have basic knowledge of Apache. This guide assumes you haven’t done additional configuration to your Apache. You must have already got Apache2 installed.
Also remember that you should always do a backup of every configuration file you change.
1. Add a new host in Ubuntu
You should only be adding new hosts if you want to develop multiples sites in your local computer. Skip this section to go to Section 2 if you just want to add virtual hosts to a remote server.
Type in the following command into your terminal, you need to sudo here: Continue reading How to set up VirtualHost in Ubuntu