Sunday, May 11, 2014

How you you setup WordPress on BlueMix?

WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL.Today I just have successfully installed wordPress on the BlueMix Platform. I will write the detail steps so you can follow me to create your blog on the BlueMix.

Firstly I will try to install wordPress on the my local machine based on Microsoft operation system.

1.Download the wordpress from the http://wordpress.org/download/,the latest version is the 3.9.1.Unzip zip file to you local drive disk.For example e:\wordpress.
2.In order to setup your php and mysql environment,here I recommended the wampserver.It is a web development platform on Windows allowing you to create dynamic web applications with Apache2, PHP and MySQL.You can download it from http://www.wampserver.com/en/.It support 32 bit and 64 bit installation based on your computer.
Notes:
If you don;t install Visual Studio 2012,you need to install Visual Studio 2012 VC 11 vcredist_x64/86.exe .http://www.microsoft.com/en-us/download/details.aspx?id=30679

3.If your installation complete,Click the tray icon of  wampserver.You can see below menu.

4.Copy the wordpress folder all files to the wamp server www folder.

5.Make your WAMP server Online and start all service.Click the phpMyAdmin link to create wordpress db.Here I create a  wordpress db.

6.When you launch the url http://localhost/wordpress you can find below error.It means we need to change some configuration.

7.Make a file copy from the wp-config-sample.php,named the wp-config.php.Change the db setting like below.The default mysql username root and empty password.

8.Also you need setup WordPress Authentication Unique Keys and Salts .You need to visit the https://api.wordpress.org/secret-key/1.1/salt/  and copy all the content to replace below lines.You can know the detail reason based on this link.

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

9.Now we can visit our local wordPress blog.You can set the blog site title and user name and password.


10.You can setup other(Plug-in,template etc) from below link.After you login into the wordPress,So now our local setting is completed.


How can I deploy it to BlueMix >

So the left work is how do I deploy it the BlueMix.Since you need to create mysql on BluxMix,the db  credentials will be different when you create mysqlservice on the Cloud.So we might need to change the wp-config.php code to support that.See below code changes.

 $services = getenv("VCAP_SERVICES");
 $services_json = json_decode($services,true);
 $mysql_config = $services_json["mysql-5.5"][0]["credentials"];

        // ** MySQL settings from resource descriptor ** //

error_log($mysql_config["name"], 0);
error_log($mysql_config["user"], 0);
error_log($mysql_config["password"], 0);
error_log($mysql_config["host"], 0);
error_log($mysql_config["port"], 0);

    define('DB_NAME', $mysql_config["name"]);
    define('DB_USER', $mysql_config["user"]);
    define('DB_PASSWORD', $mysql_config["password"]);
    define('DB_HOST', $mysql_config["host"].":".$mysql_config["port"]);
Using the cloud foundry v6 cli, login to BlueMix and deploy your modified WordPress files using a PHP buildpack runtime. 
Run the below command step by step
$ cf login -a https://api.ng.bluemix.net
# Step 1: cf create-service <service name> <service plan type> <unique service instance name>

$ cf create-service mysql 100 mysql-wordpress-service
$ cf push mysql-wordpress -b https://github.com/dmikusa-pivotal/cf-php-build-pack.git --no-manifest --no-start
$ cf bind-service mysql-wordpress mysql-wordpress-service
$ cf start mysql-wordpress

When you see the below info on the console it means your deployment is successful.
Uploading mysql-wordpress...
Uploading app files from: E:\wamp\www\wordpress
Uploading 9.9M, 1206 files
OK

Stopping app mysql-wordpress in org XXX@ibm.com / space dev as XXX@cn.i
bm.com...
OK
websocket: bad handshake
Starting app mysql-wordpress in org XX@cn.ibm.com / space dev as XXX@cn.i
bm.com...
OK

1 of 1 instances running

Launch the url http://mysql-wordpress.ng.bluemix.net/wp-admin/install.php,you can install wordPress now.



So if you have any installation issue,pls let me know.

2 comments:

  1. Awesome post thanks for sharing.In the course of recent years, blogging has progressed toward becoming something of a wonder. From advertisers endeavoring to profit on the web, to young people keeping an online diary - blogging can do everything. In this article, we should investigate a standout amongst the most imperative apparatuses for anybody hoping to begin a blog online - WordPress.Wordpress Updates service


    ReplyDelete