Linux下Apache的安装【可用】

失败的情况有很多种,但成功的路有时候只有一条。在经历了多次失败安装后,特在此将apache安装的精简步骤罗列出来供日后参考。

====================APACHE 安装方法=======================

1.安装依赖包 wget -c http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
a.安装apr

wget -c http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
tar -xf apr-1.6..tar.gz cd apr-1.6.
./configure --prefix=/usr/local/apr
make && make install

b.安装apr-util

wget -c http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
tar -xf apr-util-1.6..tar.gz
cd apr-util-1.6.
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr--config
make && make install

c.安装pcre

wget -c https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
tar -xf pcre-8.41 cd pcre-8.41
./configure --prefix=/usr/local/pcre
make && make install

2.编译安装apache
apache的下载地址为:http://mirror.bit.edu.cn/apache/httpd/

下载完解压后即可进行配置(本次的解压目录为/usr/local/httpd-2.4.37)

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-mods-shared=most --enable-so --with-included-apr

--prefix  配置说明, 指定配置文件放置目录

[root@localhost local]# pwd && ll
/usr/local
total
drwxr-xr-x. root root Jan : apache2 # apache配置目录
drwxr-xr-x. root root Jan : apr # apr配置目录
drwxr-xr-x. Jan : apr-1.6. # apr安装目录
-rw-r--r--. root root Jun apr-1.6..tar.gz # apr安装包
drwxr-xr-x. root root Jan : apr-util # apr-utill配置目录
drwxr-xr-x. Jan : apr-util-1.6. # apr-utill安装目录
-rw-r--r--. root root Oct apr-util-1.6..tar.gz # apr-utill安装包
drwxr-xr-x. root root Sep bin
drwxr-xr-x. root root Sep etc
drwxr-xr-x. root root Sep games
drwxr-sr-x. root dip Jan : httpd-2.4. #apache安装目录
-rw-r--r--. root root Oct : httpd-2.4..tar.gz #apache安装包
drwxr-xr-x. root root Sep include
drwxr-xr-x. root root Dec : java
drwxr-xr-x. root root Sep lib
drwxr-xr-x. root root Sep lib64
drwxr-xr-x. root root Sep libexec
drwxr-xr-x. root root Jan : pcre #pcre安装目录
drwxr-xr-x. Jan : pcre-8.42 #pcre安装包
-rwxr--r--. root root Jan : pcre-8.42.tar.gz
drwxr-xr-x. root root Sep sbin
drwxr-xr-x. root root Dec : share
drwxr-xr-x. root root Sep src

点击查看安装目录


可能会出现的问题 configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
解决方法: 把解压好的apr和apr-util 复制到 /httpd-2.4.33/srclib/ 中去 cp -r apr-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr cp -r apr-util-1.6.2 /usr/local/src/httpd-2.4.33/srclib/apr-util

3.重新编译 ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-mods-shared=most --enable-so --with-included-apr 看看有没有报错,没有的话继续安装 make && make install 完成安装

4.启动前准备

到apache的安装目录下编辑 httpd.conf 将指定ServerName,否则启动报错

5.Apache启停

cd ${Apache_Home}

sh apachectl start 启动

sh apachectl stop 停止

上一篇:强大!基于拖放布局的 Twitter Bootstrap 网站生成器


下一篇:OS&SYS&Shuti模块