Mac GeekeryGet your geek on. |
|
blog advertising is good for you
recent popular content
User login
|
Nothing beats having a dedicated web server apart from your Mac. The Personal Web Sharing feature of OS X may be driven by Apache, but your Mac has features (like Sleep) that make it incompatible with hosting your website... Not to mention that your cable provider generally dislikes you hosting it yourself and, in fact, often directly blocks attempts to do so. But that doesn't mean that Personal Web Sharing is a complete loss. With a few tweaks, your Mac is the perfect test bed for trying out new CMS software and for testing tweaks you're planning for your existing site. Apple provides two of the three most commonly needed tools for website management. Apache, obviously, and PHP are preinstalled, though PHP needs a bit of twiddling to enable. The last, MySQL, has previously been a small ordeal to get up and running; you could sacrifice a bit by installing ancient, precompiled binaries, or stay up to date by compiling your own mysql binaries (which would require having XCode installed). Recently, though, the creators of MySQL have started providing official and up-to-date binary installers. And, for the record, this is exactly how we tested various CMS systems during the conceptual phase of Mac Geekery. Apache SetupIn System Preferences, open the Sharing Prefpane. Click the box next to Personal Web Sharing. Done. PHP SetupIn order to enable Apache's PHP module, we just need to uncomment two lines in /etc/httpd.conf. The first line we need to change reads: #LoadModule php4_module libexec/httpd/libphp4.so Just remove the # and move on to the next line. #AddModule mod_php4.c Same deal. Just remove the # and save. Now, restart Apache. Alcyone:~ jc$ sudo apachectl graceful Password: /usr/sbin/apachectl graceful: httpd gracefully restarted All done with PHP. :-D MySQL SetupThe MySQL 4.0 Downloads page now includes an "Installer Package (Mac OS X v10.3)" download. All we need to do is get that and install it. For good measure, install the optional StartupItem package, too. After you have that installed, we just need to start the mysql process. Alcyone:~ jc$ sudo SystemStarter start MySQL Password: Starting MySQL database server Alcyone:~ jc$ By default, the only database in a MySQL install is called 'mysql'. This database is for admin data about the MySQL process... it lists the databases hosted, as well as the server's usernames and passwords and the levels of access each receives. We'll need to create a database and a user, and specify a few privs for that user. We log into MySQL using /usr/local/mysql/bin/mysql; the -u option lets us specify a user other than our current UID. Alcyone:~ jc$ /usr/local/mysql/bin/mysql -u root Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 to server version: 4.0.21-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> We need to send the message create database [database name]. Typically, I use my user name, but anything is acceptable. Another good choice would be your site name. If you already have a working MySQL setup on your production server, you probably want to set this up just like it's set up there. Then we'll add a user with all privs. The GRANT command will create a new user. Since we're going to be accessing MySQL from a local instance of Apache, we just need a localhost user. mysql> create database jc; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON *.* TO 'jc'@'localhost' -> IDENTIFIED BY 'my_password' WITH GRANT OPTION; Query OK, 0 rows affected (0.25 sec) mysql> quit Bye Alcyone:~ jc$ I bet you were hoping I'd forget to change my password when I post this, weren't you? From this point, what you do is up to you. Any sites or CMS software you install should go into your home directory's Sites folder, though you can also use /Library/WebServer/Documents. I create a subfolder with the name of the CMS I'm testing, or with the name of the site I'm tweaking, and copy all relevent files there. I keep a local copy of my files in ~/Sites/my_site, which I access in my browser using http://localhost/~jc/my_site/. Tweak away at my CSS or HTML, see what works, what doesn't, and only upload to my hosting provider when I'm happy. As you install any software that interacts with MySQL, you just need to know what to put in for the hostname, user, password, and database. If you follow my directions exactly, you'll wind up with these being:
Of course, you probably used something other than "jc". Use that instead. ;-)
About JC
Author Biography JC is a former Mac Genius and Mac-centric IT worker with a background in print advertising. He earned a reputation as a miracle worker when he saved the day at a new business pitch with the arcane knowledge that Apple’s ADB cables were nothing more than poorly shielded S-Video cables. JC runs the Heroic Efforts Data Recovery Service and writes Ungenius, a tawdry tale of the life and times of a former Mac Genius. You can contact JC via IM or via the contact form.
Post new comment
|