Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Everything on WordPress is primed for a production server, and hardly mentions info on development stuff.

I want to setup a WordPress blog locally so that its good and ready before it goes live. Are there any specific guidelines when setting up a local WordPress development environment.

What is the easiest way of creating a wordpress blog locally but one that i can, at some point, transfer to a live server?

Question Edited for WordPress answers guidelines.

share|improve this question
    
Perhaps when i mean development server i mean testing environment??? –  dom Oct 28 '11 at 17:18
    
This is a localhost/server environment setup question, not a WordPress development question. –  Chip Bennett Oct 28 '11 at 19:22
    
What is the difference between a devlopment environment and a local server eonviroment?? –  dom Nov 1 '11 at 18:00
    
Development environment vs. local server environment isn't the issue. Whichever term you use, the underlying question isn't in any way specific to WordPress or to WordPress core/Plugin/Theme development. –  Chip Bennett Nov 1 '11 at 18:07

3 Answers 3

WordPress local development environment:

Local development environments could apply to developing any type of application but there are some specific WordPress gotchas that could hinder your transition from local to dev.

The goal of a local development environment is to mimic as close as possible the production environment and allow seamless transition.

Matching URL If you plan on using the same database for production it's much easier to set your local dev to the same domain as production.

  • Open your host file: sudo nano /etc/hosts and add 127.0.0.1 your-domain.com

Move root to sites dir It's much easier to manage your WordPress install under the sites dir than /Applications/Mamp/httdocs.

Edit your vhost file adding each site mapping it to the dir location:

/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/Users/your_name/Sites/domain"
ServerName domain.com #This should be the same as what was added to your host file
</VirtualHost>

Edit your.conf files mapping your vhosts and enabling Macs built in Apache web server.

/etc/apache2/extra/httpd.conf

#Uncomment line 112:
LoadModule php5_module libexec/apache2/libphp5.so

#Change your directives line 247

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from ALL
</Directory>

#Map your vhost file line: 621
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

/etc/apache2/users/yourname.conf

<Directory "/Users/yourname/Sites/">
     Options Indexes MultiViews
     AllowOverride All
     Order allow,deny
     Allow from All
</Directory>

Start your web server Go to system preferences -> sharing and check the web sharing box.

wp-config.php Map your database host location to Mamp:

localhost:/Applications/MAMP/tmp/mysql/mysql.sock

Define local constants so you can use the same wp-config between dev and production:

if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
  include( dirname( __FILE__ ) . '/local-config.php' );
  define( 'WP_LOCAL_DEV', true ); 
} else {
  define( 'DB_NAME',     'production_db'       );
  define( 'DB_USER',     'production_user'     );
  define( 'DB_PASSWORD', 'production_password' );
  define( 'DB_HOST',     'production_db_host'  );
}

Now set you local db constants in local-config.php

Extra Tip: Use Mark Jaquith's Disable Plugins when doing dev plugin to define plugins to disable when on local. Put it in wp-content/mu-plugins and define the plugins to disable at the bottom of the file:

new CWS_Disable_Plugins_When_Local_Dev( array( 'vaultpress.php' ) );

Install WordPress It' much easier to manage installs using SVN (You will have to install the Subversion binaries for Mac first ).

When your ready for production export your db using phpmyadmin and move your files to the server.

mkdir /sites/domain-name  
cd /sites/domain-name  
svn co http://core.svn.wordpress.org/tags/3.2.1 .  
share|improve this answer

There is a step-by-step LAMP guide here: http://ubuntulinuxhelp.com/how-to-install-a-web-server-and-more-in-ubuntu-linux/

After the install, then it's a simple matter of adding WordPress.

share|improve this answer

When you say "everything was fine", what do you mean? Did you manage to get WordPress up and running on the Ubuntu VM? How far did you get?

What files did you want to transfer? WordPress installation files? Or do you mean uploading files such as images for a post? The only time I've used an FTP server was when I needed to upload the WP installation files to a remote server. But if you're working on your local machine, you can either share a local folder to your virtual machine or download the files from the virtual machine and start the installation.

Regarding MAMP, never used it but there's some info about it on WordPress Codex and this article on Smashing Magazine could help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.