ubuntu apache2 端口的改变及apache2相关问题
2011-11-11 23:37
218 查看
转自:http://hi.baidu.com/phykingpeng/blog/item/a3d009fa97c1c3cbb58f3108.html
Apache 服务经常由于ISP将TCP默认80端口封锁而无法正常运行,这时候就需要更改默认80端口为一个指定的端口。比如修改为8001.
1.进入/etc/apache2/ports.conf文件,按照下面红色的部分修改:
#######################分割线#####################################
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
#####上面的说明很重要!!!!
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 8001
###上面的两行默认为80端口
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
#######################分割线#####################################
2.再进入/etc/apache2/sites-enabled/000-default文件,按如下红色部分修改
#######################分割线#####################################
<VirtualHost *:8001> ####这里对应于新端口,默认为80
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
####该文件余下内容,省略大概4百字,嘿嘿
#######################分割线#####################################
然后,在终端中重启apache(输入sudo /etc/init.d/apache2 restart)
在浏览器中输入http://localhost:8001/或者自己的域名加端口号的方式访问,比如我这里就是http://phykingpeng.co.cc:8001/.就OK了!
Apache常见错误说明:
1.第2步若未执行容易出现404错误(Chrome提示:“Oops! This link appears to be broken.”错误。FireFox会提示Not
Found The requested URL / was not found on this server.Apache/2.2.14 (Ubuntu) Server at localhost Port 8001,为一个404Not Found错误。)
2.对于Apache,任何对配置文件的改变都需要重启Apache服务,这个算是常识了!
在Ubuntu上安装Apache,每次重启,都会出现以下错误提示:
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
解决办法
修改 httpd.conf 文件
打开终端,输入以下命令:
sudo vim /etc/apache2/httpd.conf
默认情况下,这个是一个空文件,在文件中加入以下内容:
ServerName localhost
保存文件退出,再次重启apache,错误提示没有了。
Ubuntu10.04上apache2: bad user name ${APACHE_RUN_USER}问题解决
1. 安转apache2
# sudo apt-get install apache2
2. 安装完毕后,使用命令“apache2 -k graceful”启动的时候报以下错误
apache2: bad user name ${APACHE_RUN_USER}
3. 检查/etc/apache2/apache2.conf文件,发现其中需要使用/etc/apache2/envvars文件中的以下几个环境变量
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
但是在检查这几个环境变量时发现配置的用户名合组都是存在的
4. 后来发现如果不用脚本而改用启动系统服务的方式,就可以避免上面问题
# sudo /etc/init.d/apache2
5. 将自己的html文件放置在/var/www/目录下,然后访问http://localhost/,一切ok!
Apache 服务经常由于ISP将TCP默认80端口封锁而无法正常运行,这时候就需要更改默认80端口为一个指定的端口。比如修改为8001.
1.进入/etc/apache2/ports.conf文件,按照下面红色的部分修改:
#######################分割线#####################################
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
#####上面的说明很重要!!!!
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 8001
###上面的两行默认为80端口
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
#######################分割线#####################################
2.再进入/etc/apache2/sites-enabled/000-default文件,按如下红色部分修改
#######################分割线#####################################
<VirtualHost *:8001> ####这里对应于新端口,默认为80
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
####该文件余下内容,省略大概4百字,嘿嘿
#######################分割线#####################################
然后,在终端中重启apache(输入sudo /etc/init.d/apache2 restart)
在浏览器中输入http://localhost:8001/或者自己的域名加端口号的方式访问,比如我这里就是http://phykingpeng.co.cc:8001/.就OK了!
Apache常见错误说明:
1.第2步若未执行容易出现404错误(Chrome提示:“Oops! This link appears to be broken.”错误。FireFox会提示Not
Found The requested URL / was not found on this server.Apache/2.2.14 (Ubuntu) Server at localhost Port 8001,为一个404Not Found错误。)
2.对于Apache,任何对配置文件的改变都需要重启Apache服务,这个算是常识了!
在Ubuntu上安装Apache,每次重启,都会出现以下错误提示:
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
解决办法
修改 httpd.conf 文件
打开终端,输入以下命令:
sudo vim /etc/apache2/httpd.conf
默认情况下,这个是一个空文件,在文件中加入以下内容:
ServerName localhost
保存文件退出,再次重启apache,错误提示没有了。
Ubuntu10.04上apache2: bad user name ${APACHE_RUN_USER}问题解决
1. 安转apache2
# sudo apt-get install apache2
2. 安装完毕后,使用命令“apache2 -k graceful”启动的时候报以下错误
apache2: bad user name ${APACHE_RUN_USER}
3. 检查/etc/apache2/apache2.conf文件,发现其中需要使用/etc/apache2/envvars文件中的以下几个环境变量
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
但是在检查这几个环境变量时发现配置的用户名合组都是存在的
4. 后来发现如果不用脚本而改用启动系统服务的方式,就可以避免上面问题
# sudo /etc/init.d/apache2
5. 将自己的html文件放置在/var/www/目录下,然后访问http://localhost/,一切ok!
相关文章推荐
- ubuntu apache2 端口的改变及apache2相关问题
- ubuntu apache2 端口的改变
- ubuntu apache2 端口的改变
- ubuntu apache2 端口的改变
- ubuntu apache2 端口的改变
- ubuntu apache2 端口的改变
- Ubuntu默认防火墙安装、启用、配置、端口、查看状态相关信息
- ubuntu16.04(64位)安装wps及相关问题解决
- ubuntu10.04下python相关问题
- Ubuntu默认防火墙安装、启用、配置、端口、查看状态相关信息
- 关于ubuntu 12.04 编译安装 apache2 后 启动不了的问题
- [linux]ubuntu 新建用户及相关问题
- Ubuntu安装配置记5(TOMCAT6 ,APACHE2优化,常见问题处理)
- ubuntu apache2端口配置
- ubuntu上安装phalcon相关问题
- 解决ubuntu系统下mysql乱码相关问题
- [置顶] NS2.33在Ubuntu12.10的完整安装过程及相关问题
- Ubuntu默认防火墙安装、启用、配置、端口、查看状态相关信息
- Ubuntu默认防火墙安装、启用、配置、端口、查看状态相关信息