Apache2, теперь указывающий на новую страницу по умолчанию

Мой сервер Apache2 имеет новую страницу по умолчанию: Apache2 Ubuntu Default Page (расположенный в /var/www/html/index.html)

Весь мой веб-сервер служил, файлы в: /opt/lampp/htdocs папка.

Почему это изменение произошло и как зафиксировать его?

0
задан 9 December 2016 в 03:01

1 ответ

Apache2 из репозитория Ubuntu добирается, это - местоположение по умолчанию от /etc/apache2/sites-available.

конфигурация страницы по умолчанию 000-default.conf файл в том месте.

можно или изменить ту страницу или использовать ее в качестве шаблона и сделать собственный конфигурационный файл. Если Вы хотите иметь страницу с местоположением /opt/lampp/htdocs, поскольку это - маршрут сервера, можно сделать это этим способом:

1) Копия 00-default.conf файл к новому имени. Чтобы легкий метод не забыл иметь целью, можно назвать имя файла, mywebsite.conf, чтобы иметь конфигурацию для www.mywebsite.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 www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # 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

изменение в:

<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 www.mywebsite.com
        ServerAlias mywebsite.com

        ServerAdmin webmaster@localhost
        DocumentRoot /opt/lampp/htdocs

        # We must also allow access to the new root directory; by
        # default only access to /var/www is allowed.
        <Directory /opt/lampp/htdocs>
            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

после создания виртуального хоста к веб-сайту включите эту новую конфигурацию с:

$ sudo a2ensite mywebsite.conf

система затем предложит Вам перезапускать сервер для изменений для вступления в силу, с которым можно сделать:

$ sudo systemctl restart apache2

два важных изменения:

  1. ServerName
  2. DocumentRoot

Теперь Вы можете Вы мочь получить доступ к своему веб-сайту именем, данным в ServerName или директивах ServerAlias.

я оставил комментарии в примере конфигурационных файлов для показывания вариантов, которые могут быть включены путем удаления желаемой опции "#". Также комментарии являются ценным ресурсом, объясняя параметры конфигурации.

4
ответ дан 28 September 2019 в 01:46

Другие вопросы по тегам:

Похожие вопросы: