S
S
Sergey Beloventsev2016-03-24 15:28:42
Yii
Sergey Beloventsev, 2016-03-24 15:28:42

How to set up apache 2 Yii ubuntu?

at var/www/ created diary.lc/ at /etc/apache2/sites-available/ created diary.lc.conf with the following parameters

<VirtualHost *:80>
        ServerName diary.lc
        ServerAlias www.diary.lc
        DocumentRoot /var/www/diary.lc
        <Directory /var/www/diary.lc/>
                Options Indexes FollowSymlinks
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

downloaded and installed yii2 advanced at /var/www/diary.lc and
put .htaccess there
Options +FollowSymLinks
    IndexIgnore */*
    RewriteEngine on

    # Если запрос начинается с /admin, то заменяем на /backend/web/
    RewriteCond %{REQUEST_URI} ^/admin
    RewriteRule ^admin\/?(.*) /backend/web/$1

    # Если запрос начинается с /api, то заменяем на /rest/web/
    RewriteCond %{REQUEST_URI} ^/api
    RewriteRule ^api\/?(.*) /rest/web/$1

    # Добавляем другой запрос /frontend/web/$1
    RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|rest/web|admin|api)
    RewriteRule (.*) /frontend/web/$1

    # Если frontend запрос
    RewriteCond %{REQUEST_URI} ^/frontend/web
    RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php

# Если api запрос
RewriteCond %{REQUEST_URI} ^/rest/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /rest/web/index.php

# Если backend запрос
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php

in the browser I drive diary.lc, the apache2 start page is displayed if I enter diary.lc/frontend/web/ error 404
here are the urlmanager settings
'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        'rules' => [
            'index' =>'frontend/web/index',
            '<action>'=> 'site/<action>',
            ]
        ],

tell me what is the problem

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question