Linux下Apache的安装可用
Posted 远方的夜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.2.tar.gz cd apr-1.6.2 ./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.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-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 配置说明, 指定配置文件放置目录
[[email protected] local]# pwd && ll /usr/local total 12676 drwxr-xr-x. 15 root root 4096 Jan 13 12:25 apache2 # apache配置目录 drwxr-xr-x. 6 root root 4096 Jan 13 11:52 apr # apr配置目录 drwxr-xr-x. 28 1001 1001 4096 Jan 13 11:52 apr-1.6.2 # apr安装目录 -rw-r--r--. 1 root root 1071074 Jun 12 2017 apr-1.6.2.tar.gz # apr安装包 drwxr-xr-x. 5 root root 4096 Jan 13 11:55 apr-util # apr-utill配置目录 drwxr-xr-x. 21 1001 1001 4096 Jan 13 11:55 apr-util-1.6.1 # apr-utill安装目录 -rw-r--r--. 1 root root 554301 Oct 22 2017 apr-util-1.6.1.tar.gz # apr-utill安装包 drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc drwxr-xr-x. 2 root root 4096 Sep 23 2011 games drwxr-sr-x. 12 root dip 4096 Jan 13 12:22 httpd-2.4.37 #apache安装目录 -rw-r--r--. 1 root root 9177278 Oct 22 07:13 httpd-2.4.37.tar.gz #apache安装包 drwxr-xr-x. 2 root root 4096 Sep 23 2011 include drwxr-xr-x. 3 root root 4096 Dec 23 15:14 java drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64 drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec drwxr-xr-x. 6 root root 4096 Jan 13 11:58 pcre #pcre安装目录 drwxr-xr-x. 9 1169 1169 12288 Jan 13 11:58 pcre-8.42 #pcre安装包 -rwxr--r--. 1 root root 2081413 Jan 13 11:57 pcre-8.42.tar.gz drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin drwxr-xr-x. 5 root root 4096 Dec 23 05:57 share drwxr-xr-x. 2 root root 4096 Sep 23 2011 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 停止
以上是关于Linux下Apache的安装可用的主要内容,如果未能解决你的问题,请参考以下文章
manjaro linux 安装 Apache,MariaDB,PHP(LAMP)