It is very convenient to install and configure WordPress on Max OS X Snow Leopard or higher version like Lion, because it already builds an apache2 server and php5 in the system, you just need to configure them and your wordpress site can be run!
-
Download the latest version of WordPress (3.3 as of this writing)
-
Extract and copy the "wordpress" folder to your "Sites" folder. So, in my case the full path to WordPress is: /Users/jimmy/Sites/wordpress you can rename the folder as your wanted.
If you are migrating your existing wordpress from remote server, you can just scp it to the "Sites" folder, without downloading the wordpress.
WordPress runs as user "_www" according to the rules in your httpd.conf (apache configuration) file. WordPress needs permission to modify some files during the installation process. It also needs permission to download and install plugins and updates, so it’s best to get the permissions correct now and save yourself some trouble later.
Open terminal and enter the following commands:
$ cd /Users/jimmy/Sites/
$ sudo chown -R _www wordpress
$ sudo chmod -R g+w wordpress
(Change the path on the first line to your Sites folder)
Open the file /etc/apache2/httpd.conf
At line 167 change the path of DocumentRoot to your wordpress folder
DocumentRoot "/Users/jimmy/Sites/wordpress"
At line 194 change the path of "Directory" to your wordpress folder
<Directory "/Users/jimmy/Sites/wordpress">
At line 214 change the AllowOverride option to 'All', which enable the wordpress permalinks
AllowOverride All
Enable php by uncommenting Line 115
LoadModule php5_module libexec/apache2/libphp5.so
Save the file. You'll be prompted for an administrator password.
IMPORTANT: You'll need to restart Apache before the changes go into effect. Open System Preferences, Click on "Sharing" and toggle "Web Sharing" off and back on. This will reload your httpd.conf file.
If your wordpress is new and no database set up yet, you can reference the corresponding step in this illustrated guide: http://www.thermalexposure.com/2010/09/02/install-and-configure-wordpress-on-mac-os-x-snow-leopard-step-by-step/
In my case, I am migrating remote wordpress to local, so I need to backup remote db and restore it to my local wordpress, following steps:
-
Install the "WP-DB-Backup" plugin on your remote wordpress if don't have.
-
Use this plugin to backup your db, export and download the backup file to local, then extract it. (sth like blog_wp_xxxx.sql.gz)
-
Use mysql command to create the corresponding database and user. (you can find them in your wp-config.php file)
$ mysql
$ mysql> create database yourdbname;
$ mysql> INSERT INTO user(host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'yourusername', PASSWORD('yourpassword'), 'Y', 'Y','Y');
- Run the restore command
$ mysql -h localhost -u yourusername -p yourdbname < blog_wp_xxxx.sql
You'll be asked the password of the db user.
If you are migrating the remote wordpress to your local, you need to change some configuration.
Open wp-config.php file, add 2 lines of code, in my case:
define('WP_HOME','http://10.8.1.201/~jimmy/wordpress');
define('WP_SITEURL','http://10.8.1.201/~jimmy/wordpress');
which the 'http://10.8.1.201/~jimmy/' is my personal website address that showing on the "System Preferences -> Sharing", change it as your own.
Important: After your computer restart or netword re-connection, the server address may change, you need to change the wp-config.php again.
Regarding that last bit, you can avoid having to manually change the IP address each time you restart or change internet connections by setting up a virtual host and using a static IP.
Add the following lines to /etc/apache2/extra/httpd-vhosts.conf:
...and the following lines to /etc/hosts:
After you restart the webserver, you won't have to change IP addresses again.