How to set up different document roots on OpenShift for Yii2 advanced template

天大地大妈咪最大 提交于 2019-12-08 08:59:41

问题


After I use the Yii2 advance template (https://github.com/yiisoft/yii2-app-advanced) it needs different documents roots for frontend and backend.

Set document roots of your Web server:

for frontend /path/to/yii-application/frontend/web/ and using the URL http://frontend/
for backend /path/to/yii-application/backend/web/ and using the URL http://backend/

In my local machine I have set up apache and configured the virtual host to have an alias to point to backend.

<VirtualHost ..:80>
    ServerAdmin ..
    ServerName .
    DocumentRoot "...\frontend\web"
    <Directory "...\frontend\web">
        Require all granted
    </Directory>
    Alias /backend "...d\backend\web"
    <Directory "...\backend\web">
        Require all granted
    </Directory>
</VirtualHost>

but I can't figure out how to do it in the OpenShift. Please let me know if there's any solution for this on OpenShift?


回答1:


According to this release blog post in March (https://blog.openshift.com/openshift-online-march-2014-release-blog/): The DocumentRoot is chosen by the cartridge control script logic depending on conditions in the following order:

IF php/ dir exists THEN DocumentRoot=php/  
ELSE IF public/ dir exists THEN DocumentRoot=public/  
ELSE IF public_html/ dir exists THEN DocumentRoot=public_html/  
ELSE IF web/ dir exists THEN DocumentRoot=web/  
ELSE IF www/ dir exists THEN DocumentRoot=www/  
ELSE DocumentRoot=/ 

As I’m sure you’ve guessed, this makes the new OpenShift app directory structure compatible with all major upstream PHP projects, including Drupal, WordPress, Joomla, Zend Framework Skeleton Apps and many others.




回答2:


While unfamiliar with OpenShift's structure, I did find a repo using their 'Quick Start' philosophies for using frameworks with their services. Granted, this is with Yii1, but setting document roots will be similar between that and Yii2.

This information is typically set within the protected/config/main.php file where you set the basePath.

From repo here: https://github.com/Umasankar-Natarajan/yii-example

Also, in case you didn't know, there are Yii2 repos on github that already have the backend separated from the frontend so you won't have to do recreate this on your own.

Please tell Brian to finish that novel he's been working on, Stewie.



来源:https://stackoverflow.com/questions/27241846/how-to-set-up-different-document-roots-on-openshift-for-yii2-advanced-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!