The implementation of the lamp platform installation of the database working on the standalone host

Source: Internet
Author: User

Lab Environment:

vm1:192.168.1.134, installing httpd-2.4.10,php-5.4.31

vm2:192.168.1.137, installing mariadb-5.5.39

First, compile the installation on the virtual machine VM1 httpd-2.4.10

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/CE/wKiom1PrhAbg5xwxAAHV0Y7XKRY975.jpg "title=" 2014-08-13 23_26_46-root@sueking_~-Xshell 4.jpg "alt=" Wkiom1prhabg5xwxaahv0y7xkry975.jpg "/>

1, to resolve the dependencies of the preparatory work:

# yum Install-y pcre-devel

# yum Install-y mod_ssl

# yum Groupinstall-y "Development tools"

# yum Groupinstall-y "Server Platform Development"

2. Compile and install apr-1.5.1

# Tar XF 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-1.5.3

# Tar XF apr-util-1.5.3

# CD apr-util-1.5.3

#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR

# Make && make install

4. Compile and install httpd-2.4.10

# Tar XF httpd-2.4.10.tar.bz2

# CD httpd-2.4.10

#./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd24--enable-so--enable-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-mpms-shared=all--with-mpm=event

# Make && make install

5, modify the httpd master configuration file, set the PID file path, add the following content:

Pidfile "/var/run/httpd.pid"

6. Provide SYSV service script for httpd, create script file named Httpd24 in/etc/rc.d/init.d/directory, add content:

#!/bin/bash

#

# httpd Startup script for the Apache HTTP Server

#

# Chkconfig:-85 15

# Description:apache is a world Wide Web server. It's 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 would 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 this some modules may not

# work correctly with a thread-based MPM; Notably PHP would 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 $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 "$" 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 [email protected]

Retval=$?

;;

*)

echo $ "Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

Exit 1

Esac


Exit $RETVAL

To modify execution permissions for a script:

# chmod +X/ETC/RC.D/INIT.D/HTTPD24

Add Service:

# chkconfig--add httpd24

Start the service:

# service HTTPD24 Start


Ii. compile and install the php-5.4.31 on this machine


1, to resolve the dependency relationship:

# yum Groupinstall-y "Desktop Platform Development"

# yum Install-y bzip2-devel Libmcrypt-devel;libmcrypt-devel package needs to be configured well after the Epel source can be installed

2. Compile and install php-5.4.31

# Tar XF php-5.4.31.tar.bz2

# CD php-5.4.31

#./configure--prefix=/usr/local/php--with-mysql=mysqlnd--with-openssl--with-mysqli=mysqlnd--enable-mbstring-- With-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets-- With-apxs2=/usr/local/apache/bin/apxs--with-mcrypt--with-config-file-path=/etc--with-config-file-scan-dir=/etc /PHP.D--with-bz2--enable-maintainer-zts

# Make && make install

Note Points for compilation options:

(1) The compilation of options to note is--enable-maintainer, if the compilation httpd-2.4 version using the event or worker model, this option must be specified as Zts.

(2) The--WITH-APXS2 option is the option that must be indicated when the compiled and installed PHP is called by httpd in the form of a module, and this option cannot be used if the FCGI mode is installed on the same physical host as PHP httpd.

(3) The compilation process specifies the PHP program's configuration file path and the directory location of the configuration file, the subsequent need to provide PHP configuration file, you need to copy the configuration file to the specified directory.

(4) Since MySQL is not installed on this machine, specify--WITH-MYSQL=MYSQLND,--WITH-MYSQLI=MYSQLND

To provide a configuration file for PHP:

# CP Php.ini-production/etc/php.ini


3, compile Apache configuration file httpd.conf, make Apache support PHP

# vim/etc/httpd24/httpd.conf

AddType application/x-httpd-php. php

AddType Application/x-httpd-php-source. Phps

Add the format types supported by the default home page

DirectoryIndex index.php index.html

# Service HTTPD24 Reload

4, in the HTTPD site directory to create the default home page file, type PHP, Test httpd and PHP can communicate properly

# Cd/usr/local/apache/htdocs

# vim index.php

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/D0/wKioL1PrmQjx8Sg_AABoPVSIhaQ213.jpg "title=" 2014-08-14 00_51_54-root@sueking__usr_local_apache_htdocs-xshell 4.jpg "alt=" wkiol1prmqjx8sg_aabopvsihaq213.jpg "/ >

Test results:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/D0/wKioL1PrnZuSSZM1AANaWXEGp3M862.jpg "title=" 2014-08-14 01_11_25-phpinfo (). jpg "alt=" wkiol1prnzusszm1aanawxegp3m862.jpg "/> The first VM1 is ready to be completed.


Second, install the mariadb-5.5.39 on the virtual machine VM2, use the directory:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/CF/wKiom1PrnZvQUsP5AAFH4PsL_G8708.jpg "title=" 2014-08-14 01_16_11-root@localhost_~-Xshell 4.jpg "alt=" Wkiom1prnzvqusp5aafh4psl_g8708.jpg "/>

1. Prepare the file system for data storage, create the logical volume, and create the physical disk of the logical volume as/dev/sda3

# fdisk/dev/sda650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/45/CE/wKiom1PrgL6CPjebAADk-Vc5S1c100.jpg "Title=" 2014-08-13 23_13_03-root@sueking_~-Xshell 4.jpg "alt=" wkiom1prgl6cpjebaadk-vc5s1c100.jpg "/># kpartx-af/ Dev/sda

# partx-a/DEV/SDA

# cat/proc/partitions

# Pvcreate/dev/sda3

# vgcreate Myvg/dev/sda3

# lvcreate-l 10g-n mylv MYVG

# LVS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/CF/wKioL1Prgp6hzW47AADsIdaz8TM419.jpg "title=" 2014-08-13 23_16_27-root@sueking_~-Xshell 4.jpg "alt=" wkiol1prgp6hzw47aadsidaz8tm419.jpg "/># mke2fs-t ext4/dev/ Myvg/mylv

# Vim/etc/fstab

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1PrntOx0_l4AAFqCuaYFyA841.jpg "title=" 2014-08-14 01_21_27-root@localhost_~-Xshell 4.jpg "alt=" Wkiom1prntox0_l4aafqcuayfya841.jpg "/>

2. New user to run MySQL process safely

# groupadd-r MySQL

# useradd-g mysql-r-s/sbin/nologin-m-d/mydata/data MySQL

# Chown-r Mysql:mysql/mydata/data

3. Install and initialize the mysql-5.4.31

# Tar XF mariadb-5.5.39-linux-x86_64.tar.gz-c/usr/local

# cd/usr/local

# LN-SV mariadb-5.5.39-linux-x86_64 MySQL

# Chown-r Mysql:mysql./

# scripts/mysql-install_db--user=mysql--datadir=/mydata/data; Note that the execution of this statement must be in the MySQL directory, Otherwise do not call to the MySQL directory in the bin directory in the corresponding program, will error.

# chown-r Root; After initializing the database, change the file owner in the MySQL directory to root

4. Provide the main configuration file for the MARIADB database:

# CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF

# VIM/ETC/MY.CNF

Add a line of content:

DataDir =/mydata/data

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/D0/wKioL1PrpUmAjH_3AAFkWuvlnIs988.jpg "title=" 2014-08-14 01_44_16-root@localhost__usr_local_mysql-xshell 4.jpg "alt=" Wkiol1prpumajh_3aafkwuvlnis988.jpg "/>

5. Provide SYSV service script for MySQL

# CD/USR/LOCAL/MYSQ

# CP Support-files/mysql.server/etc/rc.d/init.d/mysqld

# chmod +x/etc/rc.d/init.d/mysqld

# chkconfig--add mysqld

# Chkconfig Mysqld on

6, output MySQL man manual to the man command to find the path

# vim/etc/man.config; Add the following line

Manpath/usr/local/mysql/man

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1PrpfqgrI9VAACoE7mQaSg732.jpg "title=" 2014-08-14 01_51_55-root@localhost__usr_local_mysql_man-xshell 4.jpg "alt=" wkiom1prpfqgri9vaacoe7mqasg732.jpg "/ >

7, output MySQL header file to the System header file path/usr/include/mysql

# Ln-sv/usr/local/mysql/include/usr/include/mysql

8, output the MySQL library file path to the system library to find the path, note that this step needs to be done.

# echo "/usr/local/mysql/lib" >/etc/ld.so.conf.d/mysql.conf

# Ldconfig

# Ldconfig-v | grep MySQL

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1PrqAWS4WsEAAEWUjlB_hU337.jpg "title=" 2014-08-14 02_00_23-root@localhost__usr_local_mysql_man-xshell 4.jpg "alt=" wkiom1prqaws4wseaaewujlb_hu337.jpg "/ >

9, modify the PATH environment variable, so that the system can directly use the MySQL-related commands.

# vim/etc/profile.d/mysql.sh

Add a line of content as follows:

Export Path=/usr/local/mysql/bin: $PATH

# source/etc/profile.d/mysql.sh

# service Mysqld Start

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/D0/wKioL1Prqe6j9aHPAAGR_VghiFY117.jpg "title=" 2014-08-14 02_04_02-root@localhost_~-Xshell 4.jpg "alt=" Wkiol1prqe6j9ahpaagr_vghify117.jpg "/>

Connect to the database, open the database to allow remote connections, and test using the index.php home page of the 192.168.1.134 host:

# MySQL

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/CF/wKiom1PrrSGAhvfBAACpnZTt88Q741.jpg "title=" 2014-08-14 02_21_54-root@localhost_~-Xshell 4.jpg "alt=" Wkiom1prrsgahvfbaacpnztt88q741.jpg "/>

> Use MySQL

> Update user set host= "" where user= "root";

Edit the/usr/local/apache/htdocs/index.php file for the VM1 host, as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/D1/wKioL1Prs53jcSe1AAC6lmQywLE324.jpg "title=" 2014-08-14 02_44_18-root@sueking__usr_local_apache_htdocs-xshell 4.jpg "alt=" wkiol1prs53jcse1aac6lmqywle324.jpg "/ >

Test inside the browser. Pending completion.

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.