Install apache in Linux source code and solve common errors
1. Compile and install apache 1. Resolve dependency httpd-2.4.4 requires 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 have the ability to find it. Haha 2. Install the dependent Software Package (of course, it can be considered as the required compiling environment here !) 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 the httpd-2.4.4 tar xf httpd-2.4.4.tar.bz2cd httpd-2.4.4. /configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- ena Ble-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- with-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 any page is refreshed, and show 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) 3. Some questions about the apache file directory 1. the specific 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/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 fixed during compilation, you can simply write it): Main configuration file -------------------- the directory you specified during compilation -- prefix = default web directory of the configuration file ------------------- Location of the log file in the htdocs directory under the apache directory --------------- installation of the apache service program directory in the logs directory under the apache directory ---------- installation of 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 path is not found. apr-util path solution: You need to reinstall apr, apr-util and write out the correct file path. -- 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 redhathttpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName cause: httpd. the ServerName In the conf configuration file is inconsistent with the host, causing the solution: modify the configuration of httpd. # ServerName In the 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: mod_dir.so module Cannot be loaded. solution: the method is as follows tar-zxvf apr-1.4.6.tar.gztar-zxvf apr-util-1.5.2.tar.gzmv. /apr-1.4.6/usr/local/src/apache/srclib/apr mv. // apr-util-1.5.2/usr/local/src/srclib/apr-util. in/configure, add -- with-defined ded-apr \ -- with-pcre =/usr/local/bin/pcre-config