On the previous post we deployed a wordpress site along with a mySQL service by appfog’s built-in installation process in a very fast way. In this post we will describe the process of deploying again a wordpress site but from our local machine like as our own custom PHP app.
Step A: Sign up in appfog and it will show no app under your account. Just leave the browser. Nothing to to do there now. We will use appfog command line tool to both create and upload the files to appfog.
For that, enter the following command in your Mac OSX terminal
gem install af
After successful installation of “af” you can write the following command and provide your appfog account detail to login to the service.
Note: “af” requires Ruby 1.8.7 or newer. You should Ruby installed already in your Mac 10.6+ . If any problem occurs or you are using Windows then follow this link to resolve.
Step B: Download WordPress and unzip it in your local machine. Then open the terminal again.
Go to the wordpress directory
Make a wp-config file from the sample one
cp wp-config-sample.php wp-config.php
Edit the config file
sudo nano wp-config.php
Change the following part
/** The name of the database for <a class="zem_slink" title="WordPress" href="http://wordpress.org" target="_blank" rel="homepage">WordPress</a> */ define('DB_NAME', 'database_name_here'); /** <a class="zem_slink" title="MySQL" href="http://www.mysql.com" target="_blank" rel="homepage">MySQL database</a> username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost');
$services = getenv("VCAP_SERVICES"); $services_json = json_decode($services,true); $mysql_config = $services_json["mysql-5.1"]["credentials"]; define('DB_NAME', $mysql_config["name"]); define('DB_USER', $mysql_config["user"]); define('DB_PASSWORD', $mysql_config["password"]); define('DB_HOST', $mysql_config["hostname"]); define('DB_PORT', $mysql_config["port"]);
Save the config file by pressing ctrl+X then Y.
Step C: Now start using the appfog command line tool. Staying inside the wordpress directory, simply write the following command and press enter:
af push wordpress-custom
By this command you are creating an app to your appfog account which name will be “wordpress-custom”. Follow the next instruction on the terminal window. It will auto detect your repository/directory as PHP app. Then will ask to select your desired infrastructure. Also will ask the memory reservation size and number of instance you like to dedicate for this app. When it asks the question “Create services to bind to ‘wordpress-custom’? [yN]:” you should input “Y”. Then you should choose mySQL’s number and input it then enter. Just check the following photo of the terminal to know when you will have to stop and finish.
All are done! Go back to your appfog account on the web browser. You should see an app named “wordpress-custom” under your dashboard. Click on it. In the next page click on “Visit Live Site” button and I think you know what to do with a wordpress installation page 🙂
If you want to change any code or file and want to the push the update to live site then simply enter the following command when you are done with changes in your local repository:
af update wordpress-custom