LinuxForum.Fans
Тема

Настройка локального сервера на Ubuntu 14.04

Автор: golovenkin 25 сообщений 3001 просмотров
03.03.2015 02:24 #416224

Помогите с настройкой локального сервера на 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. Что я делаю не так?

03.03.2015 06:32 #416225

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

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

03.03.2015 07:30 #416228

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

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

03.03.2015 10:53 #416233
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

03.03.2015 10:59 #416234

#ServerName mysite

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

03.03.2015 11:03 #416235
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



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

03.03.2015 11:05 #416237

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

03.03.2015 11:08 #416238
Marley написал:
Сайт mysite называется?

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

03.03.2015 11:11 · отредактировано #416239

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

03.03.2015 11:14 #416240
Marley написал:
В браузере, чтобы подключиться mysite набираете?

да

03.03.2015 11:20 #416241

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

text

<VirtualHost *:80>

****

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

</VirtualHost>

03.03.2015 11:35 #416242

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

03.03.2015 11:39 #416243

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

text

<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>

03.03.2015 11:52 #416246

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

03.03.2015 15:11 #416282

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

03.03.2015 15:34 #416283

golovenkin,

text
Попробовал, сделал вот так:
<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

03.03.2015 15:40 #416285

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

03.03.2015 17:41 #416290
"golovenkin" написал:
если не сложно, то напишите как он должен выглядеть в моем случае?

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

03.03.2015 20:21 #416297

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

Войдите или зарегистрируйтесь, чтобы ответить.