下载httpd-2.2.16.tar.gz,解压并编译安装
接着,通过修改PREFIX/conf/目录下的配置文件,来配置Apache HTTP服务器。可以先不管,采用默认的就行。这一步暂可省略。
启动测试
现在,可以执行下述命令立即启动你的Apache HTTP服务器:
你应该可以用http://localhost/来请求你的第一个网页了,这个网页位于DocumentRoot目录下,通常是PREFIX/htdocs/ 。随后,可以这样停止服务器:
常见问题解决
80端口已占用
guangbo@guangbo-laptop:/usr/local/apache2.2.16$ sudo ./bin/apachectl -k start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
解决方法:查看占用80端口程序,用最后一个命令就行
可以看到nginx占用80端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 762/nginx
tcp6 0 0 :::8080 :::* LISTEN 995/java
查看并kill掉nginx
再次启动apache,如果启动再次有占用情况,再杀一次。我杀了两次才杀掉
ServerName问题
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
这是一个 warning,出现在apache2启动或重起时。主要是因为在配置 apache2 时,没有指定相应的主机名,即 ServerName。修改 /usr/local/apache2.2.16/httpd.conf。
在最前加入 ServerName localhost:80 即可。
浏览器输入:http://127.0.0.1/
It works!.
成功。
- tar –zxvf httpd-2.2.16.tar.gz
- cd httpd-2.2.16
- ./configure --prefix=/usr/local/apache2.2.16
- make
- //现在可以在PREFIX目录(参见上述的 --prefix 参数)下安装了,执行:
- sudo make install
- //如果是升级,安装程序不会覆盖你的配置文件和文档。
接着,通过修改PREFIX/conf/目录下的配置文件,来配置Apache HTTP服务器。可以先不管,采用默认的就行。这一步暂可省略。
- sudo gedit /usr/local/apache2.2.16/conf/httpd.conf
启动测试
现在,可以执行下述命令立即启动你的Apache HTTP服务器:
- /usr/local/apache2.2.16/bin/apachectl -k start
你应该可以用http://localhost/来请求你的第一个网页了,这个网页位于DocumentRoot目录下,通常是PREFIX/htdocs/ 。随后,可以这样停止服务器:
- $ PREFIX/bin/apachectl -k stop
常见问题解决
80端口已占用
guangbo@guangbo-laptop:/usr/local/apache2.2.16$ sudo ./bin/apachectl -k start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
解决方法:查看占用80端口程序,用最后一个命令就行
- ps auxw
- netstat –ln
- sudo netstat -lnp|grep 80
可以看到nginx占用80端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 762/nginx
tcp6 0 0 :::8080 :::* LISTEN 995/java
查看并kill掉nginx
- ps 762
- PID TTY STAT TIME COMMAND
- 762 ? Ss 0:00 nginx: master process /usr/sbin/nginx
- sudo kill -9 762
再次启动apache,如果启动再次有占用情况,再杀一次。我杀了两次才杀掉
- sudo /usr/local/apache2.2.16/bin/apachectl -k start
ServerName问题
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
这是一个 warning,出现在apache2启动或重起时。主要是因为在配置 apache2 时,没有指定相应的主机名,即 ServerName。修改 /usr/local/apache2.2.16/httpd.conf。
- sudo gedit /usr/local/apache2.2.16/conf/httpd.conf
在最前加入 ServerName localhost:80 即可。
- sudo /usr/local/apache2.2.16/bin/apachectl -k stop
- sudo /usr/local/apache2.2.16/bin/apachectl -k start
浏览器输入:http://127.0.0.1/
It works!.
成功。