Install apache in Linux source code and solve common errors.

Source: Internet
Author: User
Tags fully qualified domain name

Install apache in Linux source code and solve common errors.

Original document location

1. Compile and install apache

1. Resolve Dependencies

The httpd-2.4.4 needs a newer version of apr and apr-util, so it needs to be upgraded in advance.

There are two upgrade Methods: One is through source code compilation and installation, and the other is to directly upgrade the rpm package (Be careful! Be careful ). The following is a line using the source code. Their download path is :(~ _~) I will not talk about downloading it here. I believe you can find it.

2. Install the dependent Software Package (of course, this can be considered as the required compiling environment !)

Yum-y install pcre-devel

Yum-y install "Development Libraries)

3. If everything is ready, start installation !!

  

(1) Compile and install apr tar xf apr-1.4.6.tar.bz2 cd apr-1.4.6./configure -- prefix =/usr/local/apr make & make install

 

(2) Compile and install apr-util tar xf apr-util-1.5.2.tar.bz2 cd apr-util-1.5.2. /configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr make & make install

 

(3) Compile and install httpd-2.4.4tar xf httpd-2.4.4.tar.bz2cd httpd-2.4.4. /configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- enable-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- -pcre -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enable-modules = most -- enable-mod-shared = most -- enable-mpms-shared = most -- with-mpm = eventmake & make install

Ii. Test

1. Notes when starting apache:

Note that SELinux should be disabled before startup. apache may not work normally if it is not disabled. A good thing is about iptables (firewall). We recommend that you disable SELinux before testing.

2. Start the apache service:

# Setenforce 0

# Service iptables stop

#/Usr/local/apache/bin/apachectl start

Open the browser and enter the local ip address to check whether the page is refreshed and displayed.

It works!

Then the apache service can work easily!

For more functions, you can only modify the configuration file httpd. conf !! (I will not introduce it here)

Iii. apache file directory Problems

1. Location of the Apache configuration file installed with RPM:

/Etc/httpd/-------------------------- root directory of the Apache service program

/Etc/httpd/conf/httpd. conf --------- main configuration file

/Var/www/html --------------------- default root directory of webpage documents

/Var/log/httpd/error_log ---------- Error log File

/Var/log/httpd/access_log -------- access log file

2. directory file for source code installation (because the file directory is not compiled, you can simply write it ):

Main configuration file -------------------- the directory specified by myself during compilation -- prefix = path of the configuration file

Default web directory ----------------- install the htdocs directory under the apache directory

Log File Location ----------------- install the logs directory under the apache directory

Directory of the apache service program ---------- install the bin directory under the apache directory

Iv. Common Errors

#1 #

/Usr/local/apache/bin/httpd: symbol lookup error:/usr/local/apache/bin/httpd: undefined symbol: apr_pool_pre_cleanup_register

 

Cause: the correct apr and apr-util paths are not found. You need to reinstall apr and apr-util and write the correct file paths. -- With-apr =/usr/local/bin/apr-1-config \ -- with-apr-util =/usr/local/apr/bin/apu-1-config

#2 #

Httpd: apr_sockaddr_info_get () failed for redhat
Httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Cause: the ServerName In the httpd. conf configuration file is inconsistent with the host.

Solution: Modify the # ServerName In the httpd. conf file.

#3 #

Httpd: Syntax error on line 142 of/usr/local/apache/conf/httpd. conf: Cannot load modules/mod_dir.so into server:/usr/local/apache/modules/mod_dir.so: undefined symbol: apr_array_clear

Cause: the mod_dir.so module cannot be loaded (not detailed)

Solution:

Tar-zxvf apr-1.4.6.tar.gz tar-zxvf apr-util-1.5.2.tar.gz mv. /apr-1.4.6/usr/local/src/apache/srclib/apr mv. // apr-util-1.5.2/usr/local/src/srclib/apr-util. when configuring/configure, add -- with-defined ded-apr \ -- with-pcre =/usr/local/bin/pcre-config later, the previous content has not been modified, so we are sorry for the inconvenience !!!

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.