Страница 1 из 1
Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 09:21
mubin_yunusov
Добрый день уважаемые программисты.
При перенос сайт на VDS - хостинг выводиться ошибка:
Код: Выделить всё
Not Found (#404)
Страница не найдена.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.
© My Company 2019
Работает на Yii Framework
Файл .htaccess каталог сайта:
Код: Выделить всё
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ /web/css/$1 [L]
RewriteRule ^fonts/(.*)$ /web/fonts/$1 [L]
RewriteRule ^js/(.*)$ /web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
Файл .htaccess каталога web:
Код: Выделить всё
Order Allow,Deny
Allow from all
AddDefaultCharset utf-8
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Файл config/web.php
Код: Выделить всё
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'T-zA59xcCZGHdHvTYKSF4-5RU0YUYVua',
'baseUrl' => '',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
При обращений на сайт открывается список каталогов:
Код: Выделить всё
Index of /
[ICO] Name Last modified Size Description
[ ] LICENSE.md 2019-01-17 08:58 1.6K
[ ] README.md 2019-01-17 08:58 7.2K
[ ] Vagrantfile 2019-01-17 08:58 2.6K
[DIR] assets/ 2019-01-17 08:58 -
[ ] codeception.yml 2019-01-17 08:58 814
[DIR] commands/ 2019-01-17 08:58 -
[ ] composer.json 2019-01-17 08:58 2.1K
[ ] composer.lock 2019-01-17 08:58 117K
[DIR] config/ 2019-01-17 08:58 -
[DIR] controllers/ 2019-01-17 08:58 -
[DIR] database/ 2019-01-17 08:58 -
[ ] docker-compose.yml 2019-01-17 08:58 205
[DIR] domains_cron/ 2019-01-17 08:58 -
[DIR] mail/ 2019-01-17 08:58 -
[DIR] models/ 2019-01-17 08:58 -
[DIR] modules/ 2019-01-17 08:58 -
[ ] requirements.php 2019-01-17 08:58 5.6K
[DIR] runtime/ 2019-01-17 08:58 -
[DIR] tests/ 2019-01-17 08:58 -
[DIR] vagrant/ 2019-01-17 08:58 -
[DIR] vendor/ 2019-01-17 08:58 -
[DIR] views/ 2019-01-17 08:58 -
[DIR] web/ 2019-01-17 08:58 -
[DIR] widgets/ 2019-01-17 08:58 -
[ ] yii 2019-01-17 08:58 553
[ ] yii.bat 2019-01-17 08:58 515
При открытии web выводиться ошибка:
Код: Выделить всё
Not Found (#404)
Страница не найдена.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.
© My Company 2019
Работает на Yii Framework
Как решить эту проблему?
Спасибо.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 10:17
someweb
Зачем на VDS извращения для shared хостинга?
https://github.com/yiisoft/yii2/blob/ma ... llation.md
Код: Выделить всё
# Set document root to be "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 11:37
mubin_yunusov
someweb писал(а): ↑2019.01.17, 10:17
Зачем на VDS извращения для shared хостинга?
https://github.com/yiisoft/yii2/blob/ma ... llation.md
Код: Выделить всё
# Set document root to be "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
Сейчас у меня /etc/apache2/sites-available/domains.conf
Код: Выделить всё
<VirtualHost domains.it-service.tj:80>
ServerName domains.it-service.tj
ServerAlias domains.it-service.tj
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domains
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Вот здесь нужно изменить?
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 11:55
urichalex
Видимо да
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 12:21
mubin_yunusov
Изменил файл domains.conf (/etc/apache2/sites-available/domains.conf)
Код: Выделить всё
<VirtualHost domains.it-service.tj:80>
# use mod_rewrite for pretty URL support
RewriteEngine on
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
ServerName domains.it-service.tj
ServerAlias domains.it-service.tj
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domains/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Убрал файл .htaccess каталога web
Перезапустил апаче.
service apache2 restart
Апаче выводить сообщение об ошибке:
Код: Выделить всё
root@it-service:/var/www# service apache2 restart
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 13:01
someweb
Вы зачем Directory выкинули?
Код: Выделить всё
<VirtualHost domains.it-service.tj:80>
ServerName domains.it-service.tj
ServerAlias domains.it-service.tj
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domains/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/domains/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
</VirtualHost>
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 13:51
mubin_yunusov
someweb писал(а): ↑2019.01.17, 13:01
Вы зачем Directory выкинули?
Код: Выделить всё
<VirtualHost domains.it-service.tj:80>
ServerName domains.it-service.tj
ServerAlias domains.it-service.tj
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domains/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/domains/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
</VirtualHost>
Оставил пробовал
Код: Выделить всё
a2ensite domains.conf
service apache2 restart
Всеравно та ошибка:
Код: Выделить всё
root@it-service:/var/www# service apache2 restart
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 14:06
someweb
Смотрите логи.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.17, 14:06
dmg
вам система написала где ошибку смотреть
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 12:43
mubin_yunusov
dmg писал(а): ↑2019.01.17, 14:06
вам система написала где ошибку смотреть
Да написала вот это:
Код: Выделить всё
root@it-service:~# systemctl status apache2.service
* apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
`-apache2-systemd.conf
Active: failed (Result: exit-code) since Fri 2019-01-18 12:38:12 MSK; 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 25653 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCES
Process: 25679 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAIL
Jan 18 12:38:12 it-service apache2[25679]: * The apache2 configtest failed.
Jan 18 12:38:12 it-service apache2[25679]: Output of config test was:
Jan 18 12:38:12 it-service apache2[25679]: AH00526: Syntax error on line 12 of /
Jan 18 12:38:12 it-service apache2[25679]: Invalid command 'RewriteEngine', perh
Jan 18 12:38:12 it-service apache2[25679]: Action 'configtest' failed.
Jan 18 12:38:12 it-service apache2[25679]: The Apache error log may have more in
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Control process exited,
Jan 18 12:38:12 it-service systemd[1]: Failed to start LSB: Apache2 web server.
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Unit entered failed stat
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Failed with result 'exit
Syntax error on line 12 of /etc/apache2/sites-enabled/domains.conf: - это строка где:
Можете сказать что говорить это ошибка?
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 13:40
urichalex
a2enmod rewrite
service apache2 restart
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 14:02
mubin_yunusov
urichalex писал(а): ↑2019.01.18, 13:40
a2enmod rewrite
service apache2 restart
Выполнил:
Код: Выделить всё
root@it-service:~# sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
root@it-service:~# systemctl status apache2.service
* apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
`-apache2-systemd.conf
Active: failed (Result: exit-code) since Fri 2019-01-18 12:38:12 MSK; 1h 23mi
Docs: man:systemd-sysv-generator(8)
Process: 25653 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCES
Process: 25679 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAIL
Jan 18 12:38:12 it-service apache2[25679]: * The apache2 configtest failed.
Jan 18 12:38:12 it-service apache2[25679]: Output of config test was:
Jan 18 12:38:12 it-service apache2[25679]: AH00526: Syntax error on line 12 of /
Jan 18 12:38:12 it-service apache2[25679]: Invalid command 'RewriteEngine', perh
Jan 18 12:38:12 it-service apache2[25679]: Action 'configtest' failed.
Jan 18 12:38:12 it-service apache2[25679]: The Apache error log may have more in
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Control process exited,
Jan 18 12:38:12 it-service systemd[1]: Failed to start LSB: Apache2 web server.
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Unit entered failed stat
Jan 18 12:38:12 it-service systemd[1]: apache2.service: Failed with result 'exit
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 14:14
someweb
service apache2 restart (или systemctl restart apache2)
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 14:49
mubin_yunusov
someweb писал(а): ↑2019.01.18, 14:14
service apache2 restart (или systemctl restart apache2)
Пробовал service apache2 restart. Вроде никаких ошибок нет:
Код: Выделить всё
root@it-service:~# a2enmod rewrite
Module rewrite already enabled
root@it-service:~# service apache2 restart
root@it-service:~#
Теперь стало таким:
Файл .htaccess внутри каталог сайта:
Код: Выделить всё
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ /web/css/$1 [L]
RewriteRule ^fonts/(.*)$ /web/fonts/$1 [L]
RewriteRule ^js/(.*)$ /web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
Файл .htaccess внутри каталог web:
Код: Выделить всё
Order Allow,Deny
Allow from all
AddDefaultCharset utf-8
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 14:56
someweb
Уберите файлы .htaccess
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 15:05
mubin_yunusov
someweb писал(а): ↑2019.01.18, 14:56
Уберите файлы .htaccess
Удалил оба файлы и перезапустил апаче.
Всеравно та проблема:
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 15:35
someweb
Удалите /var/www/domains/runtime/logs/app.log
Запросите страничку один раз и посмотрите что там.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 15:54
mubin_yunusov
someweb писал(а): ↑2019.01.18, 15:35
Удалите /var/www/domains/runtime/logs/app.log
Запросите страничку один раз и посмотрите что там.
Сделал как вы просили.
Сначало удалил /var/www/domains/runtime/logs/app.log
Обновил страничку. Работал. Все отлично. Огромное Вам спасибо. Очень благодарен.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 16:04
someweb
Файл лога на это не влияет.
Re: Проблема после переноса сайт на хостинг
Добавлено: 2019.01.18, 16:40
mubin_yunusov
someweb писал(а): ↑2019.01.18, 16:04
Файл лога на это не влияет.
Да.
Возможно помогло :
что скажете?