apache2不适用于不同的端口
我希望能够在两个端口上运行apache,这两个端口具有两个不同的文档根,一个是var/www文件夹,另一个是其他文件夹。但每当我点击127.0.0.1时,第一个虚拟主机中的索引就会显示出来。 如果我点击127.0.0.1:8080 url,我希望能够访问/home/somefolder/tmp中的索引,但我得到的是浏览器无法连接到127.0.0.1:8080。我错过了什么apache2不适用于不同的端口,apache,apache2,virtualhost,virtual-hosts,Apache,Apache2,Virtualhost,Virtual Hosts,我希望能够在两个端口上运行apache,这两个端口具有两个不同的文档根,一个是var/www文件夹,另一个是其他文件夹。但每当我点击127.0.0.1时,第一个虚拟主机中的索引就会显示出来。 如果我点击127.0.0.1:8080 url,我希望能够访问/home/somefolder/tmp中的索引,但我得到的是浏览器无法连接到127.0.0.1:8080。我错过了什么 <VirtualHost *:80> ServerAdmin webmaster@localhost Docu
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /home/somefolder/tmp
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
您需要确保Apache设置为侦听端口8080,因此需要
Listen 8080
及
在主配置中设置,每个发行版的主配置都会有所不同
您可以使用以下命令检查Apache正在侦听的端口:
sudo netstat -ntlp | egrep 'apache|httpd'
听起来您会在其中看到80,但不会看到8080。您需要确保Apache已设置为侦听端口8080,因此您需要
Listen 8080
及
在主配置中设置,每个发行版的主配置都会有所不同
您可以使用以下命令检查Apache正在侦听的端口:
sudo netstat -ntlp | egrep 'apache|httpd'
听起来你会看到80,但不是8080。试试这个
Listen 80
Listen 8080
NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.1:8080
<VirtualHost 127.0.0.1:80>
#ServerName eightzero.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
#ServerName eightzeroeightzero.com
DocumentRoot /var/www-8080
</VirtualHost>
我希望这对你有帮助。在使用apache conf文件进行更改后,尝试立即重新启动/重新加载httpd/apache2: 试试这个
Listen 80
Listen 8080
NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.1:8080
<VirtualHost 127.0.0.1:80>
#ServerName eightzero.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
#ServerName eightzeroeightzero.com
DocumentRoot /var/www-8080
</VirtualHost>
我希望这对你有帮助。在使用apache conf文件进行更改后,尝试立即重新启动/重新加载httpd/apache2: 谢谢,这在我的机器上起作用,但在远程机器上不起作用。它会给我以下错误:您没有访问/访问此服务器的权限。我在上面的名称VirtualHost上输入了一个错误,现在更正为8080。但是,您的错误听起来好像缺少默认文档,或者您的文档根不存在。检查您遇到问题的根目录的配置。您指的是什么默认文档?My docroot不存在index.html或DirectoryIndex指令指定的任何内容。我建议您检查日志,看看Apache正在尝试访问哪个目录。还要确保它有读取目录的权限。谢谢,这在我的机器上有效,但在远程机器上无效。它会给我以下错误:您没有访问/此服务器的权限。我在上面的名称VirtualHost上输入了一个错误,现在更正为8080。但是,您的错误听起来好像缺少默认文档,或者您的文档根不存在。检查您遇到问题的根目录的配置。您指的是什么默认文档?My docroot不存在index.html或DirectoryIndex指令指定的任何内容。我建议您检查日志,看看Apache正在尝试访问哪个目录。还要确保它具有读取目录的权限。