📜 ⬆️ ⬇️

Cloud9 and OpenShift. Development and deployment of applications in the clouds

It just so happens that now I am practicing in one company, where it is very hard to knock out a simple program on my desktop, let alone IDE, sometimes it even turns into full weekly quests. But at the same time, in my free time, I really like to experiment. After reading the article about the online IDE and having an account in OpenShift, I decided to try and create and deploy a Yii application in the clouds.

Immediately make a reservation that the article is for beginners. Who cares go!

Link Cloud9 IDE and OpenShift .
')
As an IDE, I decided to dwell on Cloud9, I like the design and functionality . Plus, you can run the application directly in the IDE, minus - database hosting is not supported, so we will try to organize access to the database, which we will create in OpenShift.

And also, Cloud9 smiled at me because of the presence of the terminal (Alt + T), even if it’s limited.



Step 0. Create accounts if you do not already have them.

I personally use free features.
For Cloud9, these are public working environments of 128MB + 1 one private + limited terminal.
For OpenShift it is 3 small cartridges, each with 512MB RAM and 1GB disk. Cartridges are components that can be added to the application, such as databases (MySQL, PosgreSQL and MondoDB) and administration tools (phpMyAdmin, RockMongo, Cron, etc.).
For small experiments quite worthy.

Step 1. Add the key from Cloud9 to OpenShift SSH

SSH keys are known to be used for secure connections, here are some good articles.
In Cloud9, you can find the key in the Show SSH key in Your Account.



Copy it and paste this key into OpenShift, for this your Public Keys is in Your Account



Step 2. Create a working environment in Cloud9 and add the application to OpenShift

Everything is simple here, the main thing is to choose a git version of the working environment when creating an application in Cloud9. Further git will be our faithful assistant.



In OpenShift, with a flick of the mouse, we create an application with PHP 5.3.



Step 3. Add the git application repository from OpenShift to the Cloud9 workbench

After creating an application in OpenShift, you can see its git repository.



To link this repository to the working environment in Cloud9, use the following commands:

git remote add openshift -m master ssh://******.git/ git pull -s recursive -X theirs openshift master 


Step 4. We load Yii in the Cloud9 working environment and create the framework for the yii application

To load the framework yii into the application, use its git repository, adding it as a submodule:

 git submodule add git://github.com/yiisoft/yii.git yii git commit -m "added yii repository as submodule" 


Download the release we need in the repository:

 cd yii git checkout 1.1.13 cd .. git add yii git commit -m "Use yii v1.1.13" 


Now create the framework for the yii application. The webapp script is usually used for this, but it will not work as a shell. Instead, we will use the php version of the script, and yes, we need a global path to our folder.
Run the following command and get the global path:

 pwd 


We have about the following:



Now we will execute a script with this path to create an application framework:

 php yii/framework/yiic.php webapp /var/lib/stickshift/ffa13067224647beb05863058997082a/app-root/data/354172/php git 


Add all received:

 git add php git commit -m "created yii skeleton app" 


A test run of php / index.php from Cloud9 will show us a warning:

date (): it is not safe to rely on the system's timezone settings.

This is solved by adding the following to php / protected / config / main.php:

 <?php // uncomment the following to define a path alias // Yii::setPathOfAlias('local','path/to/local-folder'); date_default_timezone_set( 'UTC' ); 


And don't forget commit:

 git commit -a -m "set the default timezone to UTC" 


I want to note that the problem exists only in Cloud9, in Openshift the application runs without any warnings.



Step 5. Create a database in OpenShift and configure the connection

Of course, you can get by with the sqlite database, but for your own interest, let's configure MySQL, add a cartridge on the application page.



UPD1: Be sure to write down the issued password before completion, since after that, I never found a way to recover or change the password :(. As Urchr suggests in the comments , the login and password are stored in environment variables. You can use the Cloud9 terminal to get them and connect remotely to the application via SSH. The login is standard - admin , and the password is taken from $ OPENSHIFT_MYSQL_DB_PASSWORD.
UPD2: I could find out the address and port of the database only by putting the phpMyAdmin cartridge can also be obtained via the console in the environment variables $ OPENSHIFT_MYSQL_DB_HOST and $ OPENSHIFT_MYSQL_DB_PORT.

For administrative purposes, we also supply the phpMyAdmin cartridge.



In the same php / protected / config / main.php we set up a connection with MySQL.

That's all!

Now the application is ready for further action. All this can be done using only the browser, wherever there is Internet.

The following sources were used:
1. Look Ma, No Hands! Developing for the Cloud, in the Cloud with Cloud9 IDE
2. Create Yii Project In Cloud9

I hope that the article will be useful!

Source: https://habr.com/ru/post/165303/


All Articles