Centos 7 install apache from source

One: 1. Source code installation method: The advantage of source code installation is that users can customize software functions and install required modules. Unnecessary functions can be installed without installation, or you can choose the installation path. It
is also convenient to uninstall the software, just delete the corresponding installation directory That's it.
2. Source code method of compiling and installing process:
a. Source code installation software generally consists of the following steps: Download and decompress the source code, analyze the installation platform environment (configure), compile and install the software (make, make install)

       configure文件一般是个可执行文件,可以在当前目录下直接输入“./configure”进行软件安装的环境测试,如果提示缺少某些安装包,就需要进行安装,直到测试通过。通常的,
        源码安装都需要GCC或者CC编译器,这些编译器一般在安装系统时定制安装包中的开发工具选项下。

        make是经常用的编译命令,对于一个包含很多源文件的应用程序,使用make和makefile工具可以简单快速的解决各个源文件之间复杂的依赖关系。
      3. 源码包安装注意事项:   通过源码方式安装软件,需要把开发工具等基础模块安装号,比如 gcc、gcc-c++、libgcc、glibc、make、automake等开发工具或基础包;还要安装
                                            一些相应的开发包,一般是文件名包括dev的,比如glibc-devel、gettext-devel;还有一些开发库,比如以lib开头的开发库。

              源代码一般以 file.tar.gz  file.tar.bz2打包,file.tar.gz和file.tar.bz2格式的解包命令如下:
                 #tar  jxvf  file.tar.bz2  ;    #  tar  zxvf  file.tar.gz  解压后可发现  README或readme和INSTALL或install,这些都是安装说明;
              configure比较重要的一个参数是 --prefix,用 --prefix参数,我们可以指定软件安装目录,当不需要这个软件时,直接删除软件安装目录即可。
               #more /etc/redhat-release   (查看linux系统版本)

4. Install Apache HTTp server from source code:
1. Download http server: # wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.gz
2. Unzip: # tar zxvf httpd-2.4.46.tar.gz
3. Enter the source package: # cd httpd-2.4.46
4. View the instruction file: INSTALL or README
5.# ./configure --prefix=/usr/local/apache2 (specify Install to the directory /usr/local/apache2) --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewrite

Error: checking for ARP...no
configure:error:ARP not found.please read...
Solution: 1. Download on apr official website: https://apr.apache.org : apr 1.7.0 and apr-util 1.6.1;

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz (download apr)

               #wget   https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz  (下载 apr-util)
               解压:
                #tar  zxvf apr-1.7.0.tar.gz
                 #cd  apr-1.7.0
                 # ./configure --prefix=/usr/local/apr
                 #make   (编译)
                 # make install  (执行安装操作)
               完成 apr-1.7.0的安装
                解压  apr-util-1.6.1
                #tar  zxvf apr-util-1.6.1.tar.gz  
                # ./configure  --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr   (执行./configure,进行环境测试)
                # make  (执行编译)  报错:fatal error:  expat.h: no such file.... make:***[all-recursive]  Error 1
                 上面错误是因为缺少某个包或者库文件,可能是expat.h文件没有安装。解决: #yum install expat (不可行)   # yum install expat-devel   (错误排除)
                # make  install

After solving the error, continue to install apache and
still report an error: configure: error:APR-util not found.
Solution: # ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most- -enable-proxy-http=shared --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
still reports an error: configure: error: pcre- config for libpcre not found. (indicating that pcre has not been installed)
Solution: Download pcre on the official website of pcre: www.pcre.org: #wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
Decompress pcre: # tar zxvf pcre-8.40.tar.gz Enter the pcre directory: # cd pcre-8.40 #./configure --prefix=/usr/local/pcre (environmental monitoring)

make (compile) #make install (install pcre) (#yum -y install gcc-c++ (install c++))

          6.  继续安装apache :#./configure  --prefix=/usr/local/apache2  --enable-so  --enable-mods-shared=most  --enable-proxy-http=shared  --enable-rewrite  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre
          7.执行make报错: collect2:error:ld returned 1 exit status  解决:在app 目录下  #cp -r  apr-1.7.0 httpd-2.4.46/srclib/apr   #cp -r apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
          继续报错:解决 #./configure  --prefix=/usr/local/apache2  --enable-so  --enable-mods-shared=most  --enable-proxy-http=shared  --enable-rewrite  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre  --with-included-apr

         8.# make  (编译)
         9.# make install (安装)

No error is reported and the installation is complete. Verify that the installation is correct: Enter the installation directory: # cd /usr/local/apache2/ #cd /bin #./httpd -V (Check httpd compilation environment and version)

Guess you like

Origin blog.51cto.com/12772149/2597352