Помогите с настройкой локального сервера на Ubuntu 14.04
По умолчанию проекты для локального сервера нужно размещать в папке /var/www. Это неудобно при переустановке системы, поэтому я хочу размещать свои проекты в домашней папке. Для этого я сделал следующие шаги:
1. Создал в домашней папке папку www, в ней создал папку mysite, в ней документ index.html
2. В папке /etc/apache2/sites-available создал копию файла 000-default.conf и назвал его mysite.conf
3. В этом файле прописал пути к моей папке /home/user/www/mysite
4. Далее включил сайт командой «sudo a2ensite mysite»
5. Потом перезагрузил apache
6. Зашел в папку /etc  и отредактировал файл hosts — в первой строчке к localhost добавил mysite
Но при попытке зайти в браузере на mysite открывается та же страница, что и при адресе localhost. Что я делаю не так?

2

Почему логи не смотрите?

Нужно содержимое файла mysite.conf

No Woman No Cry...

3

почему-бы вам просто симлинк с /var/www/mysite/ на $HOME/mysite не сделать? Зачем такие сложности?

Я думаю проблема в том, что DocumentRoot у вас прописан через /srv/www, а там ссылка на /var/www/. Уж не помню, как оно в Debian'е сделано…

Карусель разнесло по цепочке за час
Всех известий — конец
Да, весна началась!
(всё к лицу подлецу, как родному отцу, не рассказывай, батя, и так всё пройдёт)

4

Marley пишет:

Нужно содержимое файла mysite.conf

пожалуйста:
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName mysite

    ServerAdmin webmaster@localhost
    DocumentRoot /home/golovenkin/www/mysite

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

5

#ServerName mysite

нужно разкомментировать и написать свой сайт.

No Woman No Cry...

6

Marley пишет:

#ServerName mysite

нужно разкомментировать и написать свой сайт.

Попробовал, сделал вот так:
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName mysite

    ServerAdmin webmaster@localhost
    DocumentRoot /home/golovenkin/www/mysite

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet



Ничего не изменилось ac

7

Сайт mysite называется?

No Woman No Cry...

8

Marley пишет:

Сайт mysite называется?

Это пока попытка настроить локальный сервер. В /home/golovenkin/www/mysite/ лежит не сайт а просто файлик index.html
И да, значит сайт называется mysite

9 (03.03.2015 11:14:10 отредактировано Marley)

В браузере, чтобы подключиться mysite набираете?
В hosts это прописано?

No Woman No Cry...

10

Marley пишет:

В браузере, чтобы подключиться mysite набираете?

да

11

У меня еще прописано приблизительно следующее:

<VirtualHost *:80>


****

    <Directory "/home/golovenkin/www/mysite">
        Options All
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>
No Woman No Cry...

12

это написано в какой части файла?

13

Вот полность рабочий конфиг:

<VirtualHost *:80>
    ServerName mysite.ru
    ServerAlias www.mysite.ru
    DocumentRoot /u01/webProjects/mysite.ru
    ErrorLog /u01/logs/mysite.ru/mysite.ru-error.log
    CustomLog /u01/logs/mysite.ru/mysite.ru-access.log combined

    <Directory "/u01/webProjects/mysite.ru">
        Options All
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>
No Woman No Cry...

14

если не сложно, то напишите как он должен выглядеть в моем случае?
папка с сайтом: /home/golovenkin/www/mysite

15

неужели никто не поможет разобраться с проблемой?

16

golovenkin,

Попробовал, сделал вот так:
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName mysite

    ServerAdmin webmaster@localhost
    DocumentRoot /home/golovenkin/www/mysite
    <Directory "/home/golovenkin/www/mysite">
        Options All
        AllowOverride All
        Require all granted
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Linux Mint 19.3 Mate Edition
Windows 7

17

Что Вы хотели этим сказать?

18

golovenkin пишет:

если не сложно, то напишите как он должен выглядеть в моем случае?

Это ответ на ваш вопрос.

Linux Mint 19.3 Mate Edition
Windows 7

19

Но вот видите ли в чем прикол: он почему-то и не работает ab Я вот поэтому и спросил - что в нем не так?

20

Смотрите логи.
===================
Вроде толковое видео по настройка Apache, PHP, Ubuntu + IDE для разработки.

http://www.youtube.com/watch?v=B4-7FxQvDhY
http://www.youtube.com/watch?v=5A01mjisrTc

No Woman No Cry...

21 (06.03.2015 19:11:58 отредактировано KuckucL#)

Такая же фигня, кстати.

Вот конфиг виртуального хоста - site1.tst.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName site1.tst
        ServerAlias www.site1.tst

        DocumentRoot /var/www/site1.tst

        <Directory /var/www/site1.tst/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog /var/www/site1.tst/logs/mysite-error.log
        CustomLog /var/www/site1.tst/logs/mysite-access.log common
        
        <Directory /var/www/site1.tst>
              Options All
              AllowOverride All
              Require all granted
    </Directory>
    
</VirtualHost>

Вот hosts:

127.0.0.1    localhost
127.0.0.1    site1.tst

Всё благополучно включается и ребутится, без ошибок и прочего.

sudo a2ensite site1.tst
sudo service apache2 reload

localhost - открывается, не вопрос. А вот http://site1.tst - "белый лист".

Было дело, работало, правда пришлось шаманить прямо в 000-default.conf другие конфиги он просто на отрез отказывался цеплять. Но сейчас и это не помогает.
Я поисковик уже затеребонькал - решения так и не нашёл.

А вот, кстати, error.log апача. Но тут я буратино ( Может кто что разглядит?

[Fri Mar 06 18:10:37.955643 2015] [mpm_event:notice] [pid 16621:tid 140536985692032] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:10:37.955942 2015] [core:notice] [pid 16621:tid 140536985692032] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:18:00.812796 2015] [mpm_event:notice] [pid 16621:tid 140536985692032] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 18:18:01.894991 2015] [mpm_event:notice] [pid 17024:tid 140130977421184] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:18:01.895294 2015] [core:notice] [pid 17024:tid 140130977421184] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:19:09.971167 2015] [mpm_event:notice] [pid 17024:tid 140130977421184] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 18:19:11.050582 2015] [mpm_event:notice] [pid 17168:tid 140660313884544] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:19:11.050840 2015] [core:notice] [pid 17168:tid 140660313884544] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:47:58.003243 2015] [mpm_event:notice] [pid 17168:tid 140660313884544] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 18:48:01.631581 2015] [mpm_event:notice] [pid 18061:tid 139654897547136] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:48:01.631842 2015] [core:notice] [pid 18061:tid 139654897547136] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:48:06.414766 2015] [mpm_event:notice] [pid 18061:tid 139654897547136] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 18:48:07.499149 2015] [mpm_event:notice] [pid 18166:tid 140035166054272] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:48:07.499431 2015] [core:notice] [pid 18166:tid 140035166054272] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:52:05.140104 2015] [mpm_event:notice] [pid 18166:tid 140035166054272] AH00493: SIGUSR1 received.  Doing graceful restart
[Fri Mar 06 18:52:05.149034 2015] [mpm_event:notice] [pid 18166:tid 140035166054272] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:52:05.149062 2015] [core:notice] [pid 18166:tid 140035166054272] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 18:54:20.926495 2015] [mpm_event:notice] [pid 18166:tid 140035166054272] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 18:54:22.007309 2015] [mpm_event:notice] [pid 18416:tid 140231594059648] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 18:54:22.007565 2015] [core:notice] [pid 18416:tid 140231594059648] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 19:00:13.722417 2015] [mpm_event:notice] [pid 18416:tid 140231594059648] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 19:00:14.807299 2015] [mpm_event:notice] [pid 18675:tid 140076723836800] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 19:00:14.807788 2015] [core:notice] [pid 18675:tid 140076723836800] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 19:04:39.705977 2015] [mpm_event:notice] [pid 18675:tid 140076723836800] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 19:04:40.786919 2015] [mpm_event:notice] [pid 18854:tid 139756413278080] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 19:04:40.787212 2015] [core:notice] [pid 18854:tid 139756413278080] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 19:05:00.414818 2015] [mpm_event:notice] [pid 18854:tid 139756413278080] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 19:05:01.498407 2015] [mpm_event:notice] [pid 18997:tid 139848667068288] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 19:05:01.498685 2015] [core:notice] [pid 18997:tid 139848667068288] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 19:06:08.973471 2015] [mpm_event:notice] [pid 18997:tid 139848667068288] AH00491: caught SIGTERM, shutting down
[Fri Mar 06 19:06:10.052877 2015] [mpm_event:notice] [pid 19131:tid 140069596641152] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 19:06:10.053167 2015] [core:notice] [pid 19131:tid 140069596641152] AH00094: Command line: '/usr/sbin/apache2'
[Fri Mar 06 19:06:29.585450 2015] [mpm_event:notice] [pid 19131:tid 140069596641152] AH00493: SIGUSR1 received.  Doing graceful restart
[Fri Mar 06 19:06:29.594946 2015] [mpm_event:notice] [pid 19131:tid 140069596641152] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Fri Mar 06 19:06:29.594983 2015] [core:notice] [pid 19131:tid 140069596641152] AH00094: Command line: '/usr/sbin/apache2'

22

KuckucL# - я бы оставил только 1 блок Directive и посмотрел логи ErrorLog и CustomLog

No Woman No Cry...

23

Marley пишет:

KuckucL# - я бы оставил только 1 блок Directive и посмотрел логи ErrorLog и CustomLog

Убрал.
ErrorLog пустой, а в CustomLog вот:

127.0.0.1 - - [06/Mar/2015:17:44:56 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:44:56 +0300] "GET /favicon.ico HTTP/1.1" 404 504
127.0.0.1 - - [06/Mar/2015:17:44:56 +0300] "GET /favicon.ico HTTP/1.1" 404 504
127.0.0.1 - - [06/Mar/2015:17:50:23 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:50:24 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:17:50:24 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:17:50:24 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:17:50:53 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:50:54 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:17:52:44 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:52:44 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:17:52:58 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:53:06 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:17:53:07 +0300] "GET /favicon.ico HTTP/1.1" 404 494
127.0.0.1 - - [06/Mar/2015:17:53:07 +0300] "GET /favicon.ico HTTP/1.1" 404 494
localhost - - [06/Mar/2015:17:59:27 +0300] "GET / HTTP/1.1" 200 425
localhost - - [06/Mar/2015:17:59:28 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:18:48:32 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:18:48:40 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:18:49:00 +0300] "GET /index.html HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:18:49:07 +0300] "GET /index.php HTTP/1.1" 200 5313
127.0.0.1 - - [06/Mar/2015:18:55:37 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:00:44 +0300] "GET /www HTTP/1.1" 404 491
127.0.0.1 - - [06/Mar/2015:19:02:16 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:05:17 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:05:17 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:05:18 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:14:18 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:14:21 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:14:22 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:15:15 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:15:15 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:15:15 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:15:16 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:15:24 +0300] "GET / HTTP/1.1" 200 425
127.0.0.1 - - [06/Mar/2015:19:15:25 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [06/Mar/2015:19:15:25 +0300] "GET / HTTP/1.1" 200 424
127.0.0.1 - - [07/Mar/2015:10:01:23 +0300] "GET /favicon.ico HTTP/1.1" 404 499
127.0.0.1 - - [07/Mar/2015:10:01:23 +0300] "GET /favicon.ico HTTP/1.1" 404 498

24

KuckucL# - видео, ссылки на которые я дал выше не смотрели?
Попробуйте. Если не получится, попробую у себя поднять на виртуалке.
Сам использую для этих целей centos.

No Woman No Cry...

25 (07.03.2015 20:38:15 отредактировано KuckucL#)

Marley пишет:

KuckucL# - видео, ссылки на которые я дал выше не смотрели?
Попробуйте. Если не получится, попробую у себя поднять на виртуалке.
Сам использую для этих целей centos.

Посмотрел.
В общем, начал править как в видео.  Перенёс папку с сайтом в /var/www/html

В конфиге хоста, к ServerName добавил .local

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName site1.tst.local


        DocumentRoot /var/www/html/site1.tst

        <Directory /var/www/html/site1.tst/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog /var/www/html/site1.tst/logs/mysite-error.log
        CustomLog /var/www/html/site1.tst/logs/mysite-access.log common
</VirtualHost>

В hosts тоже:

127.0.0.1       localhost site1.tst.local
127.0.1.1       nashville-station

Как итог - всё по прежнему не работает )) Но есть одно но! При переходе по адресу - http://site1.tst/index.php - предлагает сохранить php файл )))
http://site1.tst/index.html - так же, белый лист )

UPD: Я немного поспешил просто набрав старый адрес сайта site1.tst
Отключил дефолтный конфиг - 000-default.conf

sudo a2dissite 000-default.conf

Набрал site1.tst.local - полёт нормальный! )

Вот почему он цепляет сайты в папке /var/www/html, а в /var/www не хочет? Мне конечно не принципиально, но понять, всё же хотелось бы )
(Судя по всему нужно было просто затолкать сайт в html, все остальные манипуляции не обязательны. Хотя проверять не хочу ag)

P.S. Marley, спасибо, видео натолкнуло на хорошую мысль )