Author: Dan
-
-
Mac OS includes Apache and PHP, which is a bit handy for us developers. We all need a local environment and it helps if the local environment looks and feels a bit like the terminal ssh session we use to manage our production server. Configuration can be a little tricky however, and things change from version to version of the OS…
LAMP?
We’ll end up with a LAMP stack (more or less). LAMP is an acronym for:
- Linux
- Apache
- MySQL (or MariaDB, MongoDB)
- PHP (or Perl or Python)
Whilst Mac OS is not Linux, it’s Unix-based so it’ll do…
Steps
- Check Apache
- Enable PHP
- Add virtual host configuration
- Restart and check configuration
- Install MySQL
- Configure MySQL
- Install additional tools
Check and Run Apache
Only run the start command if required…
$ ps aux | grep httpd ... _www 431 0.0 0.0 2463684 1744 ?? S 8:23pm 0:00.00 /usr/sbin/httpd -D FOREGROUND ... $ sudo apachectl start
Enable PHP
$ sudo vi /etc/apache2/httpd.conf ... # Ensure this line is uncommented LoadModule php5_module libexec/apache2/libphp5.so ...
Virtual Host Configuration
$ less /etc/apache2/users/myusername.conf <VirtualHost *:80> DocumentRoot "/Users/myusername/Sites" ServerName myusername.local ErrorLog "/private/var/log/apache2/myusername.local-error_log" CustomLog "/private/var/log/apache2/myusername.local-access_log" common <Directory "/Users/myusername/Sites"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Check Your Work
Restarting Apache allows us to check this configuration is working. Create a directory “test” in /Users/myusername/Sites. Create a “hello world” index.html.
Restart Apache
$ sudo apachectl restart
Navigate to http://localhost/test/index.html. You should see your “hello world”.
403 Forbidden…
Argh! Pain! Apache runs under the _www user. This user needs to have 755 permissions to each directory in the heirarchy your site is located in. Chmod away…
$ chmod 755 /Users/myusername/Sites $ chmod 755 /Users/myusername $ etc...
Installing MySQL
MySQL is now distributed as a nice DMG package. Download it, install MySQL (open from the context menu if OSX complains about the legitimacy of the developer), and then install the preferences panel which adds MySQL to your preferences. Nip over to the shiny new settings pane and switch on MySQL. Check it out – it runs under a system user called mysql which has been available in MacOS installs for some time now.
$ ps aux | grep mysql _mysql 1065 ... /usr/local/mysql/bin/mysql
Additional Tools
At least install a database admin tool locally. PHPMyAdmin does the job admirably – you’ll install it hosted in your new Apache PHP environment so there’s a nice circularity there… Alternatively use a MacOS database management application.
-
Last Saturday I enjoyed a long, gentle walk along, over, around and across the south downs. Starting at Hassocks I traced a meandering perimeter around my home town of Brighton, enjoying unexpectedly bright weather and the gentle teasing chill of the first winds of winter. I was followed down from Hassocks to Clayton by a somewhat strange gentleman in board shorts and hoodie, who maintained a safe distance as might a (somewhat ineffective) spy going about reconnaissance. Emerging on to the A273 we parted ways however, as I paused to admire the northern exit from the Clayton tunnel, infamous for the horrific rail crash which resulted from a signalman’s failure on a Sunday morning in 1861. The tunnel exit is lovely though, with two turrets standing guard beside a privately owned cottage straddling the tunnel exit.
Onwards and upwards I clambered to the Jack and Jill windmills, a glimpse of which I often catch as we emerge from the tunnel on the train each morning. Atop Jill were a couple of American gents, who appeared to be up there to enjoy the view more than anything else – and why not?! I know now these were most likely members of the Jack and Jill Windmills Society , whose volunteers have been responsible for carrying out the incredible restoration work most evident on Jill, the white windmill (Jack is privately owned).
I was spurred onwards by the appearance of a somewhat elderly looking chap in jeans and workman’s polo shirt, who emerged from nowhere seemingly, smiling from a wrinkled olive-tanned face as he strode past me before breaking unexpectedly into a run, which he maintained until he was out of sight.
Now turning east along the wide chalk bridleway of the South Downs Way I walked under white clouds and intermittent bursts of blinding sunshine. I found my rhythm under duress as the light wind of the morning grew more confident in the afternoon. Spindly bushes and trees, tested by the constant bluster over the years, formed gravity-defying silhouettes against the bright backdrop of the autumn sky.
I sipped coffee from my thermos at Burnt House Pond, a dew pond, or mist pond, constructed to retain water for the grazing of sheep through the warm summer months. Whilst these ponds must certainly retain some water condensate from the dense disorientating fog and mist of the downs micro-climate, the vast majority is gathered from rainfall, the annual volume of which outstrips the evaporation significantly. But the names are evocative and I enjoyed my time beside the pond, sharing a moment with the birds and bushes enjoying the tiny hilltop oasis.
Past Ditchling beacon, with it’s concentration of dog walkers attracted to the nearby car park, I plodded on into the National Trust reserve at Blackcap. I ate lunch sheltering from a light rain under a comfy tree, polished off my coffee and ventured off the south downs way into the shallow valley of Ashcombe Bottom, with it’s feeders and fences offering a haven to hundreds of pheasants which roam the woodland, greeting the walker at every turn. Dipping off the well trodden path through the wood, I found a perfect tree for climbing, and setting my pack to one side I became a child for 15 minutes, learning the tree as I climbed it in as many ways as I could find, pausing to reflect on the sounds of the nature around me at the top.
And so on I plodded, down through the off-piste tracks of Ashcombe Bottom to rejoin the South Downs Way, across the long wound of the A27, bleeding noise over the landscape, and onward around the shallow bowl of Cold Coombes. Somewhere along the ridge over Front Hill, I crossed without fanfare from the Western to Eastern hemisphere, and turned off the Way down into Rodwell in hopes of enjoying a beer at the local pub. Fate had other plans, as it was at this point I thought to check the trains from Southease. Needless to say, they were infrequent, and so it was that I broke into a hesitant jog for the last mile or so down towards the somewhat famous swing bridge at Southease. The bridge, restored in 2010, was originally built in the late 19th century. Whilst it retains all the moving parts requisite for operation as a swing bridge, it was actually last opened in 1967, and today is a fantastic example of the engineering methods of the time – one can clearly see all of the mechanised components and imagine the bridge in action. I arrived in plenty of time to enjoy the sun setting behind the hills along which I had spent the day, illuminating the sky in a plethora of reds, pinks and oranges.
-
The floors creak in daunt books. Books line the walls of two storeys of stories and the musty perfume of crisp parchment, perfectly typeset pages of knowledge and narrative, fills the air. The weight of human creative and academic pursuit is carried on that scent. It has gravity. With each step a creak, that imposes upon that gravity, unavoidably of course until one settles on a shelf. But which shelf? No keyboard to tap on to search here, just broad categories and alphabetisation. All the better to stumble upon something a little different – a discovery of one’s own, rather than the sterile, predictable recommendation of a computer. When you’re perusing those shelves, you become the entropy in the system, the occasional mutation in the otherwise predictable algorithm which internet-bound shoppers rely upon and follow for inhuman guidance.
James Daunt, founder and namesake of this literary cornucopia, has made a success of his latest challenge at the helm of Waterstones. Once a shop which I avoided, recent experiences at Waterstones have been overwhelmingly positive. The staff are knowledgable and very helpful. The displays are interesting, relevant and varied. The shelves are well stocked. I feel compelled to purchase at Waterstones now, and branches I’ve used in Clapham and Brighton have become places of discovery similar to Daunt Books. My reading is slow enough for this to be bad news, for my backlog is growing at a tremendous rate, but you can never have enough books, can you?
In other news, I’m very excited to have managed to scrape a ticket for TEDx Brighton on 25th October. I’m particularly looking forward to hearing from Aral Balkan, whose Prometheus initiative is something I’d love to get involved in, and who is heavily involved in Code Club. I also share a (relatively passive) interest in the application of mathematical analysis to sociological phenomena with Mick Taylor, a mathematician whose OurFest experiment sounds incredibly interesting.


































