Last week we posted a guide to Install Magento 2 on OpenShift. It was just an experiment, and we didn’t intend to do anything else after we showed the proof of concept. However, since the guide has become very popular, we’ve decided to dig out a bit more into this and see if there was a less hacky way of install Magento 2 in OpenShift, and there we are glad to say that we’ve managed to get it up and running with MySQL 5.7, by using another community cartridge.
It’s been very challenging due the hard disk limitation of 1GB, and we’ve had to delete everything that wasn’t absolutely necessary, as well as give up on performance in MySQL settings to squeeze a few more extra space, but eventually it worth the effort!
The steps to spot a new instance are almost the same as in our previous post, but this time we’ve simplified them even more within a simple bash script.
All you have to do is copy and paste this in a .sh file, set your API KEY & SECRET and run it from your favourite terminal (sh filename.sh). Remember that you need to have rhc installed and your Magento API Keys (check our previous post if you need any help with that):
#!/bin/bash #CHANGE THIS SETTINGS myapp='myapp' #App name API_KEY='YOUR API KEY' API_SECRET='YOUR API SECRET' # Database settings, change them if you want USERNAME='magento' PASSWORD='123456' regex='Git remote: \K(.*) (?=Cloned)' echo Creating app... newapp=$(rhc create-app $myapp http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-nginx) echo $newapp GIT_REMOTE=`echo $newapp | grep -Po "$regex"` echo $GIT_REMOTE echo Setting env variables rhc set-env API_KEY=$API_KEY API_SECRET=$API_SECRET OPENSHIFT_MYSQL_DB_USERNAME=$USERNAME OPENSHIFT_MYSQL_DB_PASSWORD=$PASSWORD -a $myapp echo Installing cartridges rhc cartridge add -a $myapp http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-mysql rhc cartridge add -a $myapp http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-php echo Cloning repository git clone https://github.com/javilumbrales/magento2-openshift.git cd magento2-openshift git pull git checkout magento-2 echo Deploying! git remote add $myapp $GIT_REMOTE git push $myapp magento-2:master -f
That’s it, your Magento 2 instance should be up and running on http://$myapp-$namespace.rhcloud.com.
The admin url and credentials are the same (/admin123 with admin / OpenShiftAdmin123)
Please, note that after deploying the app, the gear is almost out of space, so you would only be able to add minor data/changes to it. Hopefully, it should be enough for you to test it and see how it performs, and if you like it you could always upgrade your account to get some more space.
Enjoy!
This scripts works like charm!!
The first one before this article did not work.
However, I had some git cloning errors right after deployment. before addition of cartridges.
———————————————–
Please make sure you have the correct access rights
and the repository exists.
The cartridge ‘http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-nginx’ will be downloaded and installed Application Options ——————- Domain: lunarpulse Cartridges: http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-nginx Gear Size: default Scaling: no Creating application ‘shop’ … done Waiting for your DNS name to be available … done Unable to clone your repository. Called Git with: git clone ssh://[email protected]/~/git/shop.git/ “shop” !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: Your application was created successfully but had problems during configuration. Below is a list of the issues and steps you can take to complete the configuration of your application. Application URL: http://shop-lunarpulse.rhcloud.com/ Issues: 1. We were unable to clone your application’s git repo – Unable to clone your repository. Called Git with: git clone ssh://[email protected]/~/git/shop.git/ “shop” Steps to complete your configuration: 1. Clone your git repo $ rhc git-clone shop If you continue to experience problems after completing these steps, you can try destroying and recreating the application: $ rhc app delete shop –confirm Please contact us if you are unable to successfully create your application: Support – https://www.openshift.com/support !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your application ‘shop’ is now available. URL: http://shop-lunarpulse.rhcloud.com/ SSH to: [email protected] Git remote: ssh://[email protected]/~/git/shop.git/ Run ‘rhc show-app shop’ for more details about your app.
====================================================
Anyhow the site work well. I am now looking for updating now.
Thanks
Also
ssh to the site and
php $OPENSHIFT_REPO_DIR/public/bin/magento setup:static-content:deploy
returns this.
=== frontend -> Magento/luma -> en_US ===
Unable to load theme by specified key: ‘Magento/luma’>
Admin site was corrupted after a couple of logins and changing the password.
any thoughts about this? I am trying to recover this now.