Linux 手动安装Apache

      从来没有装过Apache,下面的方式是让你快速就可以手动安装Apache:

1:到http://httpd.apache.org/download.cgi去下载Linux对应的版本,推荐2.2.1

2:找一个合适的目录,创建apache的目录,例如mkdir -p /data/softWare/apache

3:解压刚刚下载的apache的tar包到任意目录,进入该目录,执行:

./configure --prefix=/data/softWare/apache --enable-module=shared
 

 4:还是在该目录,执行make

 5:继续执行sudo make install

 6:进入/data/softWare/apache,修改conf/httpd.conf

    找到:
    #ServerName www.example.com:80
    修改为:
    ServerName 127.0.0.1:80或者ServerName localhost:80
   记得要去掉前面的“#”
    否则会出现以下错误提示:
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName 

7:切换到root用户,进入到/data/softWare/apache/bin目录下 执行./apachectl -k start

8:在浏览器里输入 http://127.0.0.1  如果提示it works,则安装成功

如果要让apache在开机的时候,自动启动服务,则有两种方式:

1:最简单的就是在/etc/rc.d/rc.local 下增加启动apache服务的命令,例如/apache的路径/apachectl -k start

2:第二种,也是比较标准的方式

   如果是ubuntu,则安装sudo apt-get install sysv-rc-conf 

   然后将apache启动脚本拷贝到/etc/rc.d/下面,更名为httpd,然后执行sysv-rc-conf httpd on就OK了

猜你喜欢

转载自bestchenwu.iteye.com/blog/1222944