CentOS6.5安装LAMP环境APACHE的安装

时间:2023-03-10 00:57:29
CentOS6.5安装LAMP环境APACHE的安装

1、卸载apr、apr-util
  [root@centos6 LAMP]# yum remove apr apr-util

2、编译安装apr-1.5.1.tar.gz
  [root@centos6 LAMP]# tar zxvf apr-1.5.1.tar.gz
  [root@centos6 LAMP]# cd apr-1.5.1
  [root@centos6 apr-1.5.1]# ./configure --prefix=/usr/local/lamp/apr-httpd
  [root@centos6 apr-1.5.1]# make
  [root@centos6 apr-1.5.1]# make install

3、编译安装apr-util-1.5.4.tar.gz
  [root@centos6 LAMP]# tar zxvf apr-util-1.5.4.tar.gz
  [root@centos6 LAMP]# cd apr-util-1.5.4
  [root@centos6 apr-util-1.5.4]# ./configure --prefix=/usr/local/lamp/apr-util-httpd --with-apr=/usr/local/lamp/apr-httpd
  [root@centos6 apr-util-1.5.4]# make
  [root@centos6 apr-util-1.5.4]# make install

4、编译安装pcre-8.35.zip
  [root@centos6 LAMP]# unzip -o pcre-8.36.zip
  [root@centos6 LAMP]# cd pcre-8.36
  [root@centos6 pcre-8.36]# ./configure --prefix=/usr/local/lamp/pcre
  [root@centos6 pcre-8.36]# make
  [root@centos6 pcre-8.36]# make install

5、编译安装apache
  [root@centos6 LAMP]# tar -zxvf httpd-2.4.10.tar.gz
  [root@centos6 LAMP]# cd httpd-2.4.10
  [root@centos6 httpd-2.4.10]# ./configure --prefix=/usr/local/lamp/apache --enable-mods-shared=all --enable-deflate --enable-speling --enable-cache  --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-so --enable-expires=shared --enable-rewrite=shared --enable-static-support --sysconfdir=/etc/httpd
--with-z=/usr/local/lamp/zlib --with-apr=/usr/local/lamp/apr-httpd --with-apr-util=/usr/local/lamp/apr-util-httpd --with-pcre=/usr/local/lamp/pcre/ --disable-userdir
  [root@centos6 httpd-2.4.10]# make && make instal

6、修改配置
  [root@centos6 httpd-2.4.10]# vi /etc/httpd/httpd.conf

  修改成 ServerName localhost:80

7、启动apache
  [root@centos6 httpd-2.4.10]# /usr/local/apache/bin/apachectl start

  浏览器访问本机IP地址,出现It works!,就OK了!

8、做成服务  [root@localhost apache]# echo "/usr/local/lamp/apache/bin/apachectl start" >> /etc/rc.d/rc.local
  [root@centos6 LAMP]# /usr/local/lamp/apache/bin/apachectl start
  [root@centos6 LAMP]# cp /usr/local/lamp/apache/bin/apachectl /etc/init.d/httpd
  [root@centos6 LAMP]# chmod +x /etc/init.d/httpd
  [root@centos6 ~]# chkconfig --add httpd
  注意:如果提示service httpd does not support chkconfig错误,解决办法:编辑/etc/rc.d/init.d/httpd在文件第二行加入         
    #chkconfig:2345 10 90
    #description:Activates/Deactivates Apache Web Server
  [root@centos6 ~]# chkconfig --level 2345 httpd on
  [root@centos6 LAMP]# service httpd restart