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

Comparing #7 with #11

Yii version

2.0

Tags

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

Content

[...]
### 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;
}
[...]