Difference between #7 and #11 of
yii2-app-advanced on single domain (Apache, Nginx)

Changes

Title unchanged

yii2-app-advanced on single domain (Apache, Nginx)

Category unchanged

How-tos

Yii version changed

2.0

Tags changed

nginx,htaccess,apache,yii2, yii2-app-advanced, nginx, single domain, apache, htaccess

Content changed

[...]
### Apache

`DocumentRoot` directive is NOT AVAILABLE in .htaccess file context! You should edit you httpd.conf or virtual host config file. Or modify corresponding setting in the hosting configuration interface.

Also make sure that `FollowSymlinks` option is active for a virtual host.
 
 
Example virtual host config:

~~~
[...]
ServerName example.com
DocumentRoot "/path/to/project/frontend/web"
    Options +FollowSymlinks
 
...
</VirtualHost>
~~~
[...]
For Nginx just use [official recommended configuration](https://github.com/yiisoft/yii2/blob/master/docs/guide/start-installation.md#user-content-recommended-nginx-configuration-) and remember to set `root` accordingly:


```php

server {
charset utf-8;
[...]
```

If you are using prettyUrl, you may need to add the following lines to your Nginx configuration:
 
 
```php
 
server {
 
location /backend {
 
        try_files $uri $uri/ /backend/index.php$is_args$args;
 
    }
 
    
 
    location / {
 
        try_files $uri $uri/ /index.php$is_args$args;
 
    }
 
}
 
```
 
 

Option 2: The Hard Way
--------
[...]
Modify file `frontend/config/main.php`:


```php

....
'components' => [
[...]
Modify file `backend/config/main.php`:


```php

....
'components' => [
[...]
Here is Nginx config, built on top of the [official recommended configuration](https://github.com/yiisoft/yii2/blob/master/docs/guide/start-installation.md#user-content-recommended-nginx-configuration-):


```php

server {
set $project_root /path/to/example.com;
[...]
# uncomment the following, if you want to enable speaking URL in the backend
#try_files $uri $uri/
/backend/web/index.php$is_args$args;

location ~ /\.(ht|svn|git) {
deny all;
}
[...]
4 0
14 followers
Viewed: 147 559 times
Version: 2.0
Category: How-tos
Written by: MadAnd
Last updated by: QuPsi
Created on: Mar 12, 2015
Last updated: 3 years ago
Update Article

Revisions

View all history