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.