Compile and install LAMP in CentOS6.5 (httpd2.4 + MySQL5.6 + PHP5.4)

Source: Internet
Author: User
Tags what is lamp

Compile and install LAMP in CentOS6.5 (httpd2.4 + MySQL5.6 + PHP5.4)

What is LAMP?
LAMP refers to a group of open-source software commonly used to build dynamic websites or servers in Linux + Apache + Mysql/MariaDB + Perl/PHP/Python, which are independent programs, however, because it is often used together, it has a higher degree of compatibility and forms a powerful Web application platform. With the rapid development of open source, open source code LAMP has been integrated with J2EE and. net commercial software has formed a three-pronged trend, and the software development project has a low investment cost in software, so it has received the attention of the entire IT industry. More than 70% of website traffic is provided by LAMP, which is the most powerful website solution.

Download the required source code package to the FTP server No. 1 of the customer's home.

------------------------------------------ Split line ------------------------------------------

FTP address: ftp://ftp1.bkjia.com

Username: ftp1.bkjia.com

Password: www.bkjia.com

Compile and install LAMP (httpd2.4 + MySQL5.6 + PHP5.4) in CentOS6.5 System on LinuxIDC.com \ 2016 )\

For the download method, see

------------------------------------------ Split line ------------------------------------------

Start httpd Installation

# Preparations before installation
Yum install wget gcc-c ++ make re2c curl-devel libxml2 libxml2-devel libjpeg-devel libpng-devel libmcrypt ready-devel zlib-devel openssl-devel freetype- devel gd-devel perl-devel ncurses-devel bison-devel libtool gettext-devel cmake bzip2 bzip2-devel pcre-devel
 
# Decompress
Tar zxvf apr-1.5.0.tar.gz
Tar zxvf apr-util-1.5.3.tar.gz
Tar zxvf httpd-2.4.7.tar.gz
 
# Rename
Music apr-1.5.0 apr
Music apr-util-1.5.3 apr-util
 
# Mobile
Mv apr-util httpd-2.4.7/srclib/
 
# Go To The httpd directory
Cd httpd-2.4.7
 
. /Configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- with-z -- with-included-apr -- enable-so -- enable-deflate = shared -- enable -expires = shared -- enable-rewrite = shared -- enable-static-support -- enable-authn-dbm = shared -- enable-cache -- enable-file-cache -- enable-mem-cache -- enable-disk-cache -- enable-mod-shared = all -- enable-ssl -- enable-cgi
 
# Compile and install httpd2.4
Make & make install
 
# Edit httpd. conf
Vi/etc/httpd. conf
 
# Find the following sentence
# ServerName www.example.com: 80
 
# Change
ServerName localhost: 80
 
# Add port 80 to iptables
Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
 
# Restart iptables
Service iptables restart
 
#################################### Start the script # ######################################## #############
#! /Bin/bash
#
# Httpd Startup script for the Apache HTTP Server
#
# Chkconfig: 2345 85 15
# Description: The Apache HTTP Server is an efficient and extensible \
# Server implementing the current HTTP standards.
# Processname: httpd
# Config:/etc/httpd/conf/httpd. conf
# Config:/etc/sysconfig/httpd
# Pidfile:/var/run/httpd. pid
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $ local_fs $ remote_fs $ network $ named
# Required-Stop: $ local_fs $ remote_fs $ network
# Shocould-Start: distcache
# Short-Description: start and stop Apache HTTP Server
# Description: The Apache HTTP Server is an extensible server
# Implementing the current HTTP standards.
### END INIT INFO
 
# 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-/usr/local/apache/logs/httpd. pid}
Lockfile =$ {LOCKFILE-/var/lock/subsys/httpd}
RETVAL = 0
STOP_TIMEOUT =$ {STOP_TIMEOUT-10}
 
# The semantics of these two functions differ from the way apachectl does
# Things -- attempting to start while running is a failure, and shutdown
# When not running is also a failure. So we just do it the way init scripts
# Are expected to behave here.
Start (){
Echo-n $ "Starting $ prog :"
LANG = $ HTTPD_LANG daemon -- pidfile =$ {pidfile} $ httpd $ OPTIONS
RETVAL =$?
Echo
[$ RETVAL = 0] & touch $ {lockfile}
Return $ RETVAL
}
 
# When stopping httpd, a delay (of default 10 second) is required
# Before SIGKILLing the httpd parent; this gives enough time for
# Httpd parent to SIGKILL any errant children.
Stop (){
Echo-n $ "Stopping $ prog :"
Killproc-p $ {pidfile}-d $ {STOP_TIMEOUT} $ 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 = 6
Echo $ "not reloading due to configuration syntax error"
Failure $ "not reloading $ httpd due to configuration syntax error"
Else
# Force LSB behaviour from killproc
LSB = 1 killproc-p $ {pidfile} $ httpd-HUP
RETVAL =$?
If [$ RETVAL-eq 7]; then
Failure $ "httpd shutdown"
Fi
Fi
Echo
}
 
# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status-p $ {pidfile} $ httpd
RETVAL =$?
;;
Restart)
Stop
Start
;;
Condrestart | try-restart)
If status-p $ {pidfile} $ httpd> &/dev/null; then
Stop
Start
Fi
;;
Force-reload | reload)
Reload
;;
Graceful | help | configtest | fullstatus)
$ Apachectl $ @
RETVAL =$?
;;
*)
Echo $ "Usage: $ prog {start | stop | restart | condrestart | try-restart | force-reload | status | fullstatus | graceful | help | configtest }"
RETVAL = 2
Esac
 
Exit $ RETVAL
####################################### Start script end ###################################### ###############
 
# Add the above STARTUP script to/etc/init. d
Vi/etc/init. d/httpd
 
# Grant execution permission
Chmod 755/etc/init. d/httpd
 
# Setting Environment Variables
Vi/etc/profile
 
# Add the following content at the end
PATH =/usr/local/apache/bin: $ PATH
Export PATH
 
# Make the modification take effect
Source/etc/profile
 
# Start httpd
Service httpd start
 
# Start startup
Chkconfig httpd on
Start mysql Installation

# Decompress mysql
Tar zxvf mysql-5.6.16.tar.gz
 
# Enter the mysql directory
Cd mysql-5.6.16
 
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql_data-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DSYSCONFDIR =/etc-cores = 1-cores = 1-cores = 1-cores = 1-cores = 1-DWITH_READLINE = 1-DMYSQL_TCP_PORT = 3306-DENABLED_LOCAL_INFILE = 1-cores = 1-DEXTRA_CHARSETS = all-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci
 
# Compile and install mysql5.6
Make & make install
 
# Create a mysql user
Useradd-s/sbin/nologin mysql
 
# Creating a data directory
Mkdir-p/data/mysql_data
 
# Granting permissions
Chown-R mysql: mysql/usr/local/mysql
Chown-R mysql: mysql/data/mysql_data
 
# Go To The mysql installation directory
Cd/usr/local/mysql/scripts/
 
# Execute the following command to initialize the database
./Mysql_install_db -- basedir =/usr/local/mysql -- datadir =/data/mysql_data -- user = mysql
 
# After the minimal installation of CentOS6.5 is completed, a my will exist in the/etc directory. cnf, You need to rename this file to another name, such as:/etc/my. cnf. old, otherwise, the file will interfere with the correct configuration of MySQL installed in the source code, resulting in failure to start.
Mv/etc/my. cnf/etc/my. cnf. old
 
# Copy my. cnf to etc.
Cp/usr/local/mysql/my. cnf/etc/
 
# Copy the startup script to/etc/init. d.
Cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld
 
# Add Port 3306 to iptables
Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
 
# Restart iptables
Service iptables restart
 
# Start mysql
Service mysqld start
 
# Start mysql at startup
Chkconfig mysqld on
 
# Setting Environment Variables
Vi/etc/profile
 
# Add the following content at the end
PATH =/usr/local/mysql/bin: $ PATH
Export PATH
 
# Make the modification take effect
Source/etc/profile
 
# Initialize some mysql settings
Mysql_secure_installation
 
# Press ENTER
Enter current password for root (enter for none ):
 
# Y: Set the mysql root Password.
Set root password? [Y/n] y
 
# Yes
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
 
ThanksforusingMySQL!
Start installing php

# Decompress php
Tar zxvf php-5.4.25.tar.gz
 
# Enter the extracted php Directory
Cd php-5.4.25
 
. /Configure -- prefix =/usr/local/php -- with-config-file-path =/etc -- with-apxs2 =/usr/local/apache/bin/apxs -- with-mysql -- with-mysqli -- with-libxml-dir -- with-png-dir -- with-jpeg-dir -- with-freetype-dir -- with-gd -- with-zlib-dir --- mcrypt -- enable-soap -- enable-mbstring = all -- enable-sockets -- enable-ftp -- enable-zip -- with-gettext
 
# Compile and install php5.4
Make & make install
 
# Setting Environment Variables
Vi/etc/profile
 
# Add the following content at the end
PATH =/usr/local/php/bin: $ PATH
Export PATH
 
# Make the modification take effect
Source/etc/profile
 
# Copy the configuration file to the etc directory
Cp/usr/src/php-5.4.25/php. ini-production/etc/php. ini
 
# Modifying the Default Time Zone
Vi/etc/php. ini
Date. timezone = Asia/Shanghai
 
# Make httpd support php Parsing
Vi/etc/httpd. conf
 
# Find this line
AddType application/x-gzip. gz. tgz
 
# Add this sentence
AddType application/x-httpd-php. php
 
# Find the following sentence and add index. php
DirectoryIndex index.html
 
DirectoryIndex index.html index. php
 
# Add a test file to/usr/local/apache/htdocs/phpinfo. php to check whether httpd can output the php page.
If you can see the following page, your lamp environment is ready.

By now, the entire lamp environment has been compiled and installed.

You may also like the following LAMP-related content:

Install Xcache and Memcached on the LAMP platform to accelerate website operation

Build a LAMP platform environment in CentOS 7

CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment

Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04

Install LAMP in Ubuntu 14.10

LAMP combines NFS to build a small blog site

Install and deploy the LAMP environment under CentOS7

This article permanently updates the link address:

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.