Compile and install the Apache httpd server and apachehttpd in Linux.

Source: Internet
Author: User

Compile and install the Apache httpd server and apachehttpd in Linux.

Environment: ubuntu 16.0.4

Apache official website download Apache httpd compressed package: httpd-2.4.27.tar.gz, please confirm to install the make tool before installation, I installed GNU make

Install APR (in fact, do not install, instructions later): Download apr-1.6.2.tar.gz

Decompress:

Sudo tar-zxvf '/home/fanchao/desktop/share/apache http server/apr-1.6.2.tar.gz'-C/etc/httpd

Compilation and installation:

Sudo
Cd/etc/httpd/apr-1.6.2 # enter the decompressed file directory sudo. /configure # Here you can add the parameter -- prefix = the directory you want to install. I didn't add it here. It is installed in the/user/loacl directory by default. /configure can add this parameter sudo makesudo make install

Install APR-UTIL (in fact, do not install, instructions later): Download apr-util-1.6.0.tar.gz

Decompress:

Sudo tar-zxvf '/home/fanchao/desktop/share/apache http server/apr-util-1.6.0.tar.gz'-C/etc/httpd

Compile and install

cd /etc/httpd/apr-util-1.6.0sudo ./configure --with-apr=/usr/local/apr/bin/apr-1-configsudo make

Here error is reported

Xml/apr_xml.c: 35: 19: fatal error: expat. h: There is no file or directory compilation terminated. /etc/httpd/apr-util-1.6.0/build/rules. mk: 206: recipe for target 'xml/apr_xml.lo' failedmake [1]: *** [xml/apr_xml.lo] Error 1 make [1]: leaving directory '/etc/httpd/apr-util-1.6.0'/etc/httpd/apr-util-1.6.0/build/rules. mk: 118: recipe for target 'all-recursive 'failedmake: *** [all-recursive] Error 1

The solution is to install libexpat1-dev

sudo apt-get install libexpat1-dev

Re-enter

sudo makesudo make install

Prce library required for httpd installation: Download prce-8.41.zip

Decompress:

Sudo unzip '/home/fanchao/desktop/share/apache http server/pcre-8.41.zip'-d/etc/httpd

Compilation and installation:

cd /etc/httpd/pcre-8.41sudo ./configuresudo make sudo make install

Finally, compile and install apache httpd

Sudo. /configure -- with-apr = '/usr/local/apr/bin/apr-1-config' -- with-apr-util = '/usr/local/apr/bin/apu-1-config' -- -prce = '/usr/local/bin/pcre-config' # other parameters can be configured here, for details, refer to the official sudo makesudo make install

Now the installation has been completed according to the instructions in the official documentation, but an error is reported when I make this step.

collect2: error: ld returned 1 exit statusMakefile:48: recipe for target 'htpasswd' failedmake[2]: *** [htpasswd] Error 1make[2]: Leaving directory '/etc/httpd-2.4.27/support'/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failedmake[1]: *** [all-recursive] Error 1make[1]: Leaving directory '/etc/httpd-2.4.27/support'/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failedmake: *** [all-recursive] Error 1

I checked this error in many places or how it happened. This error is caused by the absence of apr and apr-util in the srclib directory under the httpd directory,. /configure does not report an error. make only reports an error. Therefore, download it to the apr and apr-util directories and decompress it to the srclib directory to the apr and apr-util directories. Note that the directory names must be consistent.

This is why I mentioned earlier that apr and apr-util are not required to be installed. It will be installed automatically and an error will be reported if you specify the installation path after manual installation.

Regenerate the make file and make

Sudo./configure -- with-prce = '/usr/local/bin/pcre-config' -- with-supported ded-apr # For other parameters, see the official sudo makesudo make install

Now you can install it successfully. If no folder is specified, it will be installed in/usr/local/apache2

Run

Sudo '/usr/local/apache2/bin/apachectl'-k start # start sudo '/usr/local/apache2/bin/apachectl'-k stop # stop

End.

 

 

    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.