5th November 2009 at 2:55 pm

Running WordPress on OS X 10.6 Snow Leopard Server

I previously ran my WordPress blog on an OS X client operating system. I’ve just bought a new Mac Mini running Snow Leopard Server to replace the old Mac Mini.

In theory it should be a lot more straight forward on the Server version of the operating system as everything you need is pre-installed. In practice, once you know what you need to do, it’s quite simple – but finding these things out is not so simple. In the hope this will help others here is my 4 step plan for getting Snow Leopard Server ready for WordPress.

Server Admin

Step 1 – Enable Short Open tags in PHP – otherwise you will likely see blank screens in your Web browser and errors like this in your Apache log: “Parse Error: syntax error, unexpected $end in ..”. Search for “short_open_tag” in /private/etc/php.ini and change it so it reads “short_open_tag = On”

Step 2 – Enable MySQL – Although it’s pre-installed, it’s not running by default and it’s not necessarily obvious if you are new to Snow Leopard Server, what to do to enable it. Open Server Admin and make sure your server is selected. Then click on the [+] icon in the bottom left corner and choose “Add Service”. Find “MySQL” and select the check box then press [Save]. After this if you click on the triangle next to the sever name it should expand to show a list of services including MySQL. Select MySQL then the Settings Icon. Here you can enable network access, set the Root password and finally click on the [Start MySQL] button at the bottom of the window.

Step 3 – Enable re-writes – required for Permalinks to work. Still in Server Manager – click on “Web” in the list of services and then click on Sites. if you are not using Virtual Hosts – just select the default site, otherwise create your virtual host and keep that selected. Next, click on the “Options” button for your site and check the box next to “Allow All Overrides”, then press [Save].

Step 4 – Enable PHP5 – Still on the Web Service in Server Manager, select “Settings” and then click on the [Modules] button. Scroll down and find “php_5_module” and click on the check box to enable it. Press [Save] and then stop and start the Web service using the button at the bottom of the window.

And that’s it – your server should have everything it needs to install a working WordPress Blog

Notes:

This will allow you to get WordPress running on your server but there are other things that you should consider that are out of scope of this post, like NOT using your root user in MySQL for the WordPress database.

if you didn’t enable the Web service or SMTP mail as part of the install – you can enable them in the same manner you enabled MySQL.

  • Jeff

    where do you find step 1

  • http://www.kevinleah.co.uk Kevin Leah

    Jeff, You won't see /private/etc/php.ini in Finder, I assume this is what you mean?

    You will need to use Terminal (In Utilities) and a command line editor. I would use vi but if you are unfamiliar with command line editors, you might find pico easier to use.

    Launch Terminal

    Make a backup copy of the file before you change it

    sudo cp /private/etc/php.ini /private/etc/php.ini.bak
    (you will need to enter your password.)

    Then open the file in pico:

    sudo pico /private/etc/php.ini

    Scroll down until you get to the line you need to change and make the necessary changes.

    Then press
    [CTRL]o
    [Enter]
    [CTRL]x

  • http://www.jespera.se/ JesperA

    I was using this post to try to set up my Mac Mini Server and yes this guide works but i am a complete beginner when it comes to MySQL on Snow Leopard Server, i want to connect to use Sequel Pro on my Desktop to connect to the server but i get this message when trying to do so:

    “MySQL said: Host 192.168.0.199 is not allowed to connect to this MySQL server”

    Anyone know what i should do?

  • http://www.kevinleah.co.uk Kevin Leah

    I suspect it's all about privileges. The default setup on my server is that you can only administer from the localhost, e.g. the server. To allow you to administer from your desktop, you are going to have to grant the necessary privileges, something like:
    GRANT ALL ON database TO username@'host' IDENTIFIED BY 'password'; (Don't try this, it is not a real example.)

    I am by no means an expect on MySQL and I prefer to use phpmyadmin rather than the command line. There is a WordPress plugin for this and once you have in installed you can use a web browser to configure the privileges.

    http://wordpress.designpraxis.at/plugins/wp-php

  • http://www.jespera.se/ JesperA

    Yeah you where right, i had to grant user privileges to be able to remotely connect to MySQL!

    Thank you for your help and this guide is really great for setting up WordPress on OSX SL Server

  • http://www.jespera.se/ JesperA

    Sorry, i didnt ment to use you as a OSX Server support guy but i am having some minor problem with running WordPress on OS X Server:

    If i login on my WordPress site i get redirected to the WordPress Admin section as usual, but when i go back to my homepage i am not logged in, its only when i refresh my browserwindow i am logged in, i dont think it is a cookie problem on my computer since a couple of my other websites that is running on Ubuntu is doing fine!

    I wonder if OS X Server is caching in a wrong way, i have removed the caching modules in Server Admin but it behaves the same!

    Have you encountered this problem or have any suggestions of what could be wrong?

    Thank you

  • http://javiermartinez.es backd00r

    I'm having the same issue than you! Snow Leopard is caching in a wrong way. Did you solved the problem?

    Regads,
    Javier

  • http://www.jespera.se JesperA

    Yes i maybe have the solution for you, just maybe!

    This one took a long time to figure out, alot of late nights and hairpulling and so on!

    I have narrowed it down to be the way that OS X Server handles HTTP Header caching, it is totally fine and works really good on static content and alot of dynamic content to but for some reason WordPress doesnt play so well with it!

    Go to your Sites folder in /etc/apache2/sites and open the text file that corresponds to your WordPress domain (make sure you have write permissions in that folder)

    Once you open the file you will se the <directory “folder”></directory> directive

    Inside the <directory> directive simply add these lines:

    Header Set Cache-Control “max-age=0″
    <FilesMatch “.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$”>
    Header set Cache-Control “public”
    Header set Expires “Thu, 15 Apr 2011 20:00:00 GMT”
    Header unset Last-Modified
    </FilesMatch>
    <FilesMatch “.(js|css)$”>
    Header set Cache-Control “public”
    Header set Expires “Thu, 15 Apr 2011 20:00:00 GMT”
    Header unset Last-Modified
    </FilesMatch>

    The first line will remove the OS X Server Header caching and the FilesMatch function will then add back Header Caching to files that you want to cach directly, if you dont use the FileMatch function nothing will be cached!

    So if you wanna use caching for your PHP files just install wp-super-cache and now EVERYTHING will be cached right, atleast for me it does!

    So if this works for you, please reply back so i can start using this workaround in a bigger scale!

  • http://javiermartinez.es backd00r

    JesperA

    I've installed wp-super-cache and it seems to work now.

    Thanks for your help!
    Javier

  • http://twitter.com/scoopz Scoopz (Neil Cooper)

    I’ve never used the server version of OS X before but have managed to tweak a standard OS X install to host multiple sites on my Mac Pro.

    I recently bought the new Mac Mini Server with Snow Leopard Server (SLS) installed to take over from my Mac Pro. Setting up SLS was much easier than I thought and I have two websites hosted on their successfully including a wordpress site. Which seems fully operational BUT I cannot utilise the auto-update plugins/themes feature.

    I have enabled the FTP service, added the folder hosting the site as an Alias and that eliminated the “Cannon find wp content folder error” and it now finds the folder correctly, it downloads the updates, unpacks into the update folder, deletes the old version but then fails trying to copy the updated files back to the plugin directory.

    I don’t know what else to do. If I FTP from a normal FTP client I can read and write to the plugins directory perfectly.

    Has any body come across this before?

    Scoopz

    • http://www.kevinleah.co.uk Kevin Leah

      From memory this has nothing to do with running the FTP server on Snow Leopard. I don’t have the FTP service enabled but the updates work fine. I think that the problem can be solved by making sure that All WordPress files are owned by the user account the httpd runs as. I hesitate to give further guidance as I am not an expert on Unix file permissions.

      • http://twitter.com/scoopz Scoopz (Neil Cooper)

        Thanks for getting back to me [didn't get an email notification of a reply though unless it ended up in spam but bookmarked your page for future ref].
        I had a feeling it might be to do with the “group” that owns the wordpress files so I’m just searching for more info on this now.

        Scoopz

        • http://www.kevinleah.co.uk Kevin Leah

          Try a Google search for “wordpress chown update” it might help. On Snow Leopard Server, httpd runs under user _www

  • Hugh

    I too am starting out with SLS and am wondering where do I install WP? I would imagine that it would be /Library/WebServer/ Is this best practice for where to install WP or is there a better option?

  • http://twitter.com/jamusreynolds Jamie Reynolds

    Thanks. Helpful stuff.

  • Andrew

    This has be be the best post I have seen on WordPress and Mac OS 10 server, most post are written like the person being talked to knows all about programming already.

    I have done what you said, but I am have trouble getting my WordPress site up and running, I got to the point where WordPress tries creates a WP-config.php file, it makes me copy the text and create my own, which I do. But then it does not recognize the file I make and keeps asking me to create on, even showing a web page displaying the config file date to any that go to the URL, which is not cool like my passwords and stuff. So I have to change the config files’ name, at which point it asks for all the data needed to create a config file again.

    I have a feeling this may have to do with permissions, but I don’t really know what that is or how to change it.

    I would also like to know how to create another MySQL log-in besides root so I don’t have to use root.

    • http://www.kevinleah.co.uk Kevin Leah

      Thanks for the praise. Unfortunately I am by no means an expert so I’m not sure I can help, but I’ll give it a go.

      With regard to the config file, how are you creating it? Can you open up the Terminal App from Utilities and type:
      ls -l /fullpathtowordpress/wp-config.php
      e.g.
      ls -l /ServiceData/Web/wordpress/wp-config.php
      (-l is a lowercase L)

      Post the output here.

      With regard to creating a SQL user. I use either phpMyAdmin or Webmin – both provide a web based GUI for managing MySQL

  • Bidone01

    Don’t know if you still check this blog, I have the same setup with a mac mini Mac OSX server 10.6.8 I have installed wordpress and all works well, but i have multiple sites on the server is there a way of using word press on multiple sites? what i mean at the moment only one site uses wordpress and the mysql path points to its directory, but I can see how to create another one. If you know please let me know thanks.

  • Bidone01

    correction: “but I Cannot see how to create another one”