Как изменить местоположение localhost?
Я установил apache2, mysql, php и phpmyadmin . Корневое местоположение находится в /var/www
сейчас, но я хотел изменить его на что-то вроде /home/user/sites
или что-то. В других потоках решением было добавить некоторый код в 000-default.conf
файл в sites-enabled
папка, но в моей папке такого файла нет, в действительности нет файла в /etc/apache2/sites-enabled
папка. Так как мне изменить местоположение сейчас?
$ ls -l /etc/apache2/sites-enabled
total 0
$ ls -l /etc/apache2/sites-available
total 16
-rw-r--r-- 1 root root 1582 अक्टूबर 17 07:26 000-default.conf
-rw-r--r-- 1 root root 1338 अक्टूबर 13 22:51 000-default.conf~
-rw-r--r-- 1 root root 6432 जुलाई 21 2013 default-ssl.conf
$ apt-cache policy apache2
Installed: 2.4.6-2ubuntu2.2
Candidate: 2.4.6-2ubuntu2.2
Version table:
*** 2.4.6-2ubuntu2.2 0
500 http://np.archive.ubuntu.com/ubuntu/ saucy-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu/ saucy-security/main i386 Packages
100 /var/lib/dpkg/status
2.4.6-2ubuntu2 0
500 http://np.archive.ubuntu.com/ubuntu/ saucy/main i386 Packages
Содержание 000-default.conf
является:
$ cat /etc/apache2/sites-enabled/000-default.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 /home/buffhead/Sites
# 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
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
DocumentRoot /home/buffhead/Sites/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/buffhead/Sites/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
И содержание нового DocumentRoot:
$ ls -l /home/buffhead/Sites/
total 4
-rw-r--r-- 1 root root 25 अक्टूबर 13 15:12 info.php
1 ответ
Чтобы изменить местоположение по умолчанию, отредактируйте /etc/apache2/sites-available/000-default.conf
, Затем сделайте:
sudo a2ensite 000-default.conf
sudo service apache2 restart
И обновитесь до Ubuntu 14.04, пока вы на нем. 13.10 устарела и больше не поддерживается.
Ошибка разрешения может быть из-за отсутствия доступа к /home/buffhead/Sites/
папка. Делать:
chmod o+x /home/buffhead
chown :www-data -R /home/buffhead/Sites/
chmod g+rxs /home/buffhead/Sites/
Это должно позволить apache получить доступ к файлам в /home/buffhead/Sites/
и файлы, созданные в нем, должны сохранять www-data
группа.