Install and configure the LAMP environment in CentOS 6.4
System Environment: CentOS 6.4
Software source package version:
Httpd-2.4.10
Php-5.4.32
Mysql-5.5.39
I. Compile and install apache2.4
1. download the required software source code package and use the wget command to download it:
Apr-1.5.1: wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.1.tar.bz2
Apr-util-1.5.3: wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.3.tar.bz2
Httpd-2.4.10: wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.10.tar.bz2
2. Resolve Dependencies
(1) Use yum to install some dependent libraries required by the system
Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses-devel curl- devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel nss_ldap openldap-clients openldap-servers pcre-devel
(Note: In this installation experiment, you only need to install openssl, openssl-devel, pcre, and pcre-devel in yum to compile httpd normally and the libraries and tools listed above, many of them have been installed in the system. Here we only need to update them, and some other libraries are used to prepare for compiling and installing mysql and php below)
(2) Compile and install apr first
Tar jxf apr-1.5.1.tar.bz2
Cd apr-1.5.1
./Configure -- prefix =/usr/local/apr
Make & make install
(3) Compile and install apr-util.
Tar jxf apr-util-1.5.3.tar.bz2
Cd apr-util-1.5.3
. /Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr # (note: -- with-apr =/usr/local/apr is the path for installing apr)
Make & make install
(Explanation: apr, all called Apache portable Run-time libraries, is called Apache portable Runtime Library, it mainly provides an underlying support interface library for upper-layer applications that can be used across multiple operating system platforms. To install apache, you must first install this library)
3. Official compilation and installation of httpd
Tar jxf httpd-2.4.10.tar.bz2
Cd httpd-2.4.10
. /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 = all -- with-mpm = event
Make & make install
-------------------------------------- Split line --------------------------------------
Install and configure LAMP in CentOS 6.5
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment
Ubuntu-based LAMP optimization and Reinforcement
-------------------------------------- Split line --------------------------------------
4. Configure httpd
(1) provide the sysv Service Startup and shutdown scripts for httpd, and copy the following content into/etc/init. d/httpd and grant this file execution permission (chmod + x/etc/rc. d/init. d/httpd), you can directly use the service httpd <start | stop | restart | reload> command to control the httpd service:
#! /Bin/bash
#
# Httpd Startup script for the Apache HTTP Server
#
# Chkconfig:-85 15
# Description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# Processname: httpd
# Config:/etc/httpd/conf/httpd. conf
# Config:/etc/sysconfig/httpd
# Pidfile:/var/run/httpd. pid
# Source function library.
./Etc/rc. d/init. d/functions
If [-f/etc/sysconfig/httpd]; then
./Etc/sysconfig/httpd
Fi
# Start httpd in the C locale by default.
HTTPD_LANG =$ {HTTPD_LANG-"C "}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# Mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS = ""
# Set HTTPD =/usr/sbin/httpd. worker in/etc/sysconfig/httpd to use a server
# With the thread-based "worker" MPM; be warned that some modules may not
# Work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
Apachectl =/usr/local/apache/bin/apachectl
Httpd =$ {HTTPD-/usr/local/apache/bin/httpd}
Prog = httpd
Pidfile =$ {PIDFILE-/var/run/httpd. pid}
Lockfile =$ {LOCKFILE-/var/lock/subsys/httpd}
RETVAL = 0
Start (){
Echo-n $ "Starting $ prog :"
LANG = $ HTTPD_LANG daemon -- pidfile =$ {pidfile} $ httpd $ OPTIONS
RETVAL =$?
Echo
[$ RETVAL = 0] & touch $ {lockfile}
Return $ RETVAL
}
Stop (){
Echo-n $ "Stopping $ prog :"
Killproc-p $ {pidfile}-d 10 $ httpd
RETVAL =$?
Echo
[$ RETVAL = 0] & rm-f $ {lockfile }$ {pidfile}
}
Reload (){
Echo-n $ "Reloading $ prog :"
If! LANG = $ HTTPD_LANG $ httpd $ OPTIONS-t> &/dev/null; then
RETVAL =$?
Echo $ "not reloading due to configuration syntax error"
Failure $ "not reloading $ httpd due to configuration syntax error"
Else
Killproc-p $ {pidfile} $ httpd-HUP
RETVAL =$?
Fi
Echo
}
# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status-p $ {pidfile} $ httpd
RETVAL =$?
;;
Restart)
Stop
Start
;;
Condrestart)
If [-f $ {pidfile}]; then
Stop
Start
Fi
;;
Reload)
Reload
;;
Graceful | help | configtest | fullstatus)
$ Apachectl $ @
RETVAL =$?
;;
*)
Echo $ "Usage: $ prog {start | stop | restart | condrestart | reload | status | fullstatus | graceful | help | configtest }"
Exit 1
Esac
Exit $ RETVAL
(2) Add the httpd service as self-starting upon startup:
Chkconfig -- add httpd
Chkconfig httpd on
(3) modify the httpd main configuration file/etc/httpd. conf, specify the PID file of the httpd service, and add the following fields directly in the configuration file:
PidFile "/var/run/httpd. pid"
(4) Start the httpd service and perform access tests.
Service httpd start
(Note: If this warning occurs at startup: httpd: apr_sockaddr_info_get () failed for longren
Httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName. Solution: Add ServerName 127.0.0.1 to/etc/httpd. conf)
Access test: http: // your_ipadress. If It Works appears, the httpd compilation and installation are successful.
For more details, please continue to read the highlights on the next page: