우분투 13.10에서 가상 호스트를 만드는 방법
-
21-12-2019 - |
문제
저는 우분투 13.10 OS와 LAMP, Apache 2.4를 사용하고 있습니다.
아파치에 가상호스트를 만들고 싶습니다.몇 가지 코드를 시도했지만 작동하지 않았습니다.
다음과 같이 수정되었습니다.하지만 작동하지 않습니다.
먼저 내가 변했다 HostnameLookups off
에게 HostnameLookups on
~에 etc\apache2\apache2.conf
파일.그런 다음 아래 코드를 추가했습니다.
<VirtualHost *:80>
ServerName local.scholarships.theiet.in
DocumentRoot /home/www/my_project/public_html
<Directory path_to_code_base/public>
Options -Indexes
Require all granted
DirectoryIndex index.php
AllowOverride All
</Directory>
</VirtualHost>
아파치를 다시 시작한 후 나는 달렸다 http://localhost/
.사이트가 로드되지 않았습니다.
실행할 때 내 사이트를 어떻게 로드할 수 있나요? http://localhost/
해결책 3
이는 생성하는 또 다른 방법입니다. 우분투 13.10의 가상 호스트
아래 예에서는 가상 호스트를 생성하는 방법을 보여줍니다.
1 단계:라는 이름의 PHP 프로젝트를 만듭니다. site1.com
~에 /home/user/www/
2 단계:변화 HostnameLookups off
에게 HostnameLookups on
~에 /etc/apache2/apache2.conf
3단계:이름이 지정된 구성 파일을 만듭니다. site1.com.conf
~에 /etc/apache2/sites-available/
이 코드를 다음에 추가하세요. site1.com.conf
,
<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
ServerAdmin info@site1.com
DocumentRoot /var/www/site1.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/site1.com">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
4단계:그런 다음 추가 127.0.0.1 site1.com
에게 /etc/hosts.txt
5단계:터미널을 열고 명령을 실행하십시오.
sudo a2ensite site1.com
sudo /etc/init.d/apache2 restart
6단계:브라우저를 열고 실행 http://site1.com/
이 시도
다른 팁
여기에 Apache / Ubuntu에서 미험적 호스트를 생성 할 수있는 방법은 다음과 같습니다.
내 000-default.conf 파일 :
<VirtualHost *:80>
DocumentRoot /var/www/php/frbit/l4blog/public/
<Directory /var/www/php/frbit/l4blog/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ServerName l4blog
</VirtualHost>
.
servername 을 만들었습니다. 이것은 내 새 호스트의 이름입니다.
다음과 같이 / etc / hosts 파일에 새 호스트 이름을 추가 할 수 있습니다.
127.0.0.1 your_host_name
.
긴 URL을 입력하지 마십시오.
대신에http://localhost/path/directory/file/...
.
주소 표시 줄에 your_host_name 을 입력 할 수 있습니다.
your_host_name
. 사이트 사용 가능한 디렉토리의 구성 파일 파일 이름은 이제 ".conf"로 끝나야하므로 / etc / apache2 / sites - example.com.conf 스타일의 이름을 따서 명명합니다.다음을 모델링하십시오 :
<VirtualHost *:80>
ServerAdmin you@example.com
ServerName www.example.com
DocumentRoot /var/www/example.com
<Directory />
Options FollowSymLinks
Options Indexes FollowSymLinks MultiViews
AllowOverride All
require all granted
</Directory>
ErrorLog /var/log/apache2/example.com.error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/example.com.access.log combined
</VirtualHost>
.
Apache에서 사용 가능 :
$ sudo a2ensite example.com
.
(나중에 사용할 수 없으면 $ sudo a2dissite example.com)
/ etc / hosts 파일에 행을 추가해야 할 수도 있습니다.
127.0.0.1 example.com
.
A2Ensite로 사이트를 Apache에 추가했지만 Apache를 다시 시작해야합니다.