For various reasons, an user might want editing httpd.conf on OpenShift PaaS. Here is how you can edit and making it working on restart. We have quite good number of articles on OpenShift PaaS, one can use the search feature on this website to get the search result like a list of article by using OpenShift as keyword to search. First you need to know about the Cloud Computing Service Models. Second thing is that, PaaS is not exactly like a cPanel webhosting.
OpenShift has a free tier of usage simply because, when launched, it was intended for the developers. PaaS came with offers but initially had no standards “ the big providers presented strategies for Platform as a Service. There are reasons to use PaaS as well as there are shortcomings.
Editing httpd.conf on OpenShift : First Things First
You will need Shell Access on OpenShift, which is possible through the command line tool. Basic UNIX commands and their own commands can be executed on OpenShift PaaS Cloud. MySQL supports interactive mode as well. We have a basic guide on using OpenShift Command Line Tool. We have a small video guide on OpenShift SSH too, please click watch it on YouTube and click the gear icon on YouTube to select the highest resolution (1080p HD).
Editing httpd.conf on OpenShift
May be, you need to make an apache directory alias and define a directory with some permissions. If you add some herdoc statements to deployment script, commit the change, and pushed to rhc, it will not work. Ensure that httpd is installed :
---
1 | sudo yum install httpd |
We basically need to create a small environment for Apache to run with your username. Our user is abhishekghosh so, should create a directory on this path => /home/abhishekghosh/this-example/
. Commands are easy :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | mkdir -p ~/this-example/ # this-example is just an example cd ~/this-example/ # let us create directory for logs, html for static pages, a directory (etc) for configuration, # conf.d for any more changes to Apache mkdir logs run html etc conf.d # copy from original location cp /etc/httpd/conf/httpd.conf etc/ # edit httpd config file looking like this Listen 127.1.2.3:8080 # default is # Listen 80 # 127.1.2.3 is as per documentation # Edit ServerRoot directory ServerRoot œ/home/abhishekghosh/this-example/ # default is /etc/httpd # change abhishekghosh/this-example/ DocumentRoot œhtml/ # it was different by default # symlink the modules ln -s /usr/lib64/httpd/modules/ modules # or ln -s /usr/lib/httpd/modules/ modules # check version of httpd, i.e. 64bit httpd, 32bit httpd etc |
The following command should also start Apache httpd:
1 | httpd -f ~/this-example/etc/httpd.conf |
What we wrote up to this is :
1 2 3 4 | https://github.com/openshift/origin-server/tree/master/cartridges/openshift-origin-cartridge-mock # docs http://openshift.github.io/documentation/oo_cartridge_developers_guide.html http://openshift.github.io/documentation/oo_cartridge_guide.html |
You can clone or download the repo zip from github:
1 | https://github.com/openshift/origin-server/archive/master.zip |
Up to this is a way.
But in case you want an alias pointing to the files outside of the ApacheDocument root, assuming FollowSymLinks is enabled in the cartridge, so all you need is to create a symlink. Here is the Apache conf file :
1 2 3 4 5 6 7 | Alias /your-public-alias "/path/to/outside/of/document/root" <Directory "/path/to/outside/of/document/root"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> |
1 | ln -s /path/to/outside/of/document/root ${OPENSHIFT_REPO_DIR}/sub-directory/your-public-alias |
The .htaccess file inside of /path/to/outside/of/document/root will override all. Just restart :
1 | rhc app restart |