龙空技术网

Linux安装部署Apache(杰哥教你Linux)

了了CHEN心 338

前言:

目前我们对“linuxapache配置目录”大体比较珍视,姐妹们都想要分析一些“linuxapache配置目录”的相关内容。那么小编在网上网罗了一些对于“linuxapache配置目录””的相关内容,希望兄弟们能喜欢,大家一起来了解一下吧!

1. Apache HTTP Server

地址:

2. APR 和 APR-Util

地址:

3. PCRE

地址:

二. 安装

1. 如果没有安装gcc/gcc-c++的话必须安装

[root@localhost /]#gcc -v

gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)

## 这个结果就是有gcc,那么就不需要看下面的安装gcc了

[root@localhost /]# yum list

##一种可能的搜索结果如下:有包但没安装

Avaliable Packages

gcc-c++.x86_64

如果结果中没有gcc-c++,或者只有”gcc-c++ Avaliable Packages”没有”gcc-c++ Installed”的话就说明需要安装,安装代码如:[root@localhost /]# yum install gcc-c++

2. 安装APR、APR-Util、PCRE、Apache Http Server

将这些都安装在/usr/local中,先mkdir目录如下:[root@localhost soft]# mkdir /usr/local/httpd[root@localhost soft]# mkdir /usr/local/apr[root@localhost soft]# mkdir /usr/local/apr-util[root@localhost soft]# mkdir /usr/local/pcre

然后步骤如下(直接顺序复制粘贴):

[root@localhost soft]# tar -zxf apr-1.5.2.tar.gz[root@localhost soft]# tar -zxf apr-util-1.5.4.tar.gz[root@localhost soft]# tar -zxf pcre-8.38.tar.gz[root@localhost soft]# tar -zxf httpd-2.4.18.tar.gz[root@localhost soft]# cd apr-1.5.2[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.5.2]# make[root@localhost apr-1.5.2]# make install[root@localhost apr-1.5.2]# cd ../apr-util-1.5.4[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config[root@localhost apr-util-1.5.4]# make[root@localhost apr-util-1.5.4]# make install[root@localhost apr-util-1.5.4]# cd ../pcre-8.38[root@localhost pcre-8.38]# ./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config[root@localhost pcre-8.38]# make[root@localhost pcre-8.38]# make install[root@localhost pcre-8.38]# cd ../httpd-2.4.18[root@localhost httpd-2.4.18]# ./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util[root@localhost httpd-2.4.18]# make[root@localhost httpd-2.4.18]# make install

三、yum安装

## 先yum list看看有没有你可以的包 yum list httpd ## 如果有的话,比如我用x86_64版,就可以安装。 yum install httpd.x86_64

四、配置、启动Apache

httpd.conf是主配置文件,你可以按需更改,一般来说可能需要自定义端口,那么就vim修改httpd.conf文件的监听端口,改为你希望的。启动、关闭、重启[root@localhost bin]# ./apachectl start[root@localhost bin]# ./apachectl stop[root@localhost bin]# ./apachectl restart

五、Apache设置为Linux系统服务,并开机启动

将链接apachectl 复制到系统启动目录下并命名为httpd

[root@localhost bin]# cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd

到此,其实已经可以使用service httpd start等命令,但在linux服务列表还没有注册

使用chkconfig来注册apache服务,并其可以在linux的服务列表中看到(chkconfig –list)在init.d的httpd链接文件中第2行添加如下注释,并wq保存退出

[root@localhost bin]# vim /etc/rc.d/init.d/httpd

意义如下35:在3级别和5级别(级别见文末TIPS)启动httpd61:启动顺序为61号,S6161:关闭顺序为61号,K61当进行chkconfig --add httpd操作时,如果没有指定level那么就会来这个注释中取值。将httpd配置自启并加入linux服务监控

[root@localhost bin]# chkconfig --add httpd

此时,就可以在rc.d下的相应的3和5目录下看到S61httpd,并在0、1、2、4、6目录看到K61httpd了。

这是2步的手动设置方式,不想看可以跳过。可以手动设置自启动:将链接apachectl放一份软链接到rc3.d目录下(和/或rc*.d目录下)

[root@localhost bin]# ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd

标签: #linuxapache配置目录 #linux无法启动apache2 #startapacheservice #linux编译安装apache开机启动