Install Apache with the source code in Ubuntu12.04

Source: Internet
Author: User
Environment: Ubuntu12.04 [simple installation] The first installation of Apache is generally smooth. 1. Download and decompress the official website address: unzip

Environment: Ubuntu 12.04

[Simple installation]

Generally, the first installation of Apache is smooth.

1. Download and decompress

Official website address: http://httpd.apache.org/

root@ubuntu:/home/qy/share# tar zxvf httpd-2.2.22.tar.gzroot@ubuntu:/home/qy/share# cd httpd-2.2.22

There are files README and INSTALL in the http-2.2.22, which can be read with the more command.

2. Configuration

root@ubuntu:/home/qy/share/httpd-2.2.22# ./configure --prefix=/usr/local/apache

The -- prefix parameter specifies the directory to be installed. This directory does not exist in/usr/local. It will only appear after make install.

Note: During installation of Apache, the system does not check whether the parameters are correct. The incorrect parameters are discarded and not reported to users. So echo $? Command to check whether there is an error. If the output result is 0, it indicates no error.

3. Compile

root@ubuntu:/home/qy/share/httpd-2.2.22# make

4. Installation

root@ubuntu:/home/qy/share/httpd-2.2.22# make install

5. Start the server

root@ubuntu:/home/qy/share/httpd-2.2.22# cd /usr/local/apache/binroot@ubuntu:/usr/local/apache/bin# ./apachectl start

For future convenience, you can copy the Startup File apachectl to/sbin, and then directly start apachectl start.

# Vi/etc/rc. local

Add a line/sbin/apachectl start

6. Verify that Apache is working

In this case, the server window should display:

# Ps-e | grep httpd

Enter the Server IP address (or http: // localhost) in the client browser. IE should display: It works! Image.

After Ubuntu is restartedRestart Apache: Apachectl start

Stop server:./apachectl stop

Restart the server:./apachectl graceful or./apachectl restarted

Generally, there is no problem when you install Apache for the first time, but if you do not have apr, apr-util, or pcre, you may encounter the following errors during the configuration of./configure:

Make [2]: *** [install] Error 1

Make [2]: Leaving directory '/tmp/httpd-2.2.22/srclib/apr-util'

Make [1]: *** [install-recursive] Error 1

Make [1]: Leaving directory '/tmp/httpd-2.2.22/srclib'

Make: *** [install-recursive] Error 1

Apache2.0.x and Apache2.2.x differ essentially in apr. The former depends on the public apr, and the latter depends on its own apr. 2.0.x compilation basically has no issues with apr, unless the apr required for non-2.0.x is installed before compilation. If so, you need to remove the installed apr, then compile. HTTP Sever2.2.22 fixes many important security issues, including APR (Apache Portable Runtime) 1.4.5 and APR-util (Apache Utility Library) 1.4.2. Therefore, you do not need to install apr and apr-util from external sources like other online tutorials. After removing the apr that already exists in the system before installation, compile the apr and apr-util in apache2.2.x srclib. Other operating systems can solve this problem, but Ubuntu is not the same. After apr and apr-util are installed, the following error may occur when./configure configures Apache:

Configure: error: Cannot use an external APR with the bundled APR-util

Or

Configure: error: APR version 1.2.0 or later is required

The srclib directory contains three source code packages: apr, apr-util, and pcre. pcre is unavailable and cannot be compiled. The following error occurs:

Libtool: compile: unrecognized option '-DHAVE_CONFIG_H'

Libtool: compile: Try 'libtool -- help' for more information.

Make: *** [pcrecpp. lo] Error 1

Bytes. Run the make check command to check the error details. Generally, it is suspected that the version of g ++ is low. Update the version. Instead, I directly installed pcre with the apt-get install libpcre3-dev, and then installed apache is okay.

Related Article

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.