Ubuntu下安装Apache


本安装方式是在Ubuntu下采用tar包源码得方式安装。
去官方下载apache2.2.17 源码包:http://www.apache.org/dist/httpd/httpd-2.2.17.tar.gz

1.解压缩httpd-2.2.17.tar.gz 到临时目录如~/httpd-2.2.17

sudo tar zxvf httpd-2.2.17.tar.gz  ~/http-2.2.17
2.进入~/apache目录,执行
sudo ./configure --prefix=/usr/server/apache2 --enable-module=so
sudo make
sudo make install
实际执行过程中可能要求你有root权限,所以要求使用sudo

3.启动和停止apache
启动:sudo /usr/server/apache2/bin/httpd -k start
启动时提示:
httpd: Could not determine the servers fully qualified domain name, using 127.0.0.1 for ServerName.
解决办法是在http.conf中加一行:
ServerName 127.0.0.1:80
否则,只能在本地用127.0.0.1访问,不能使别的电脑访问网站

停止:sudo /usr/server/apache2/bin/httpd -k stop

4.让Ubuntu开机自动启动apache.
1). 复制 /usr/server/apache2/bin/apachectl到/etc/init.d
2). 加载为服务
     sudo update-rc.d apachectl defaults

开机重启访问http://localhost/如果显示apache的网页,就说明自动启动成功了。

相关内容

    暂无相关文章