installation of lamp under Linux

Source: Internet
Author: User


This paper mainly introduces the installation of lamp.

Linux+apache+mysql/mariadb+perl/php/python a group of open-source software that is often used to build dynamic Web sites or servers is itself a separate program, but because it is often used together, it has a higher degree of compatibility, Together make up a powerful Web application platform


The environment and installation package used in this document are CENTOS6.5+HTTPD 2.4.6+mysql-5.5.33+php-5.4.19+xcache-3.0.3.


First, compile and install Apache


1. Solve the dependency relationship


httpd-2.4.6 requires a newer version of APR and Apr-util, so it needs to be upgraded beforehand. There are two ways to upgrade, one is to compile the installation through source code, and the other is to upgrade the RPM package directly. Here you choose the way to compile the source code.

(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) The httpd-2.4.6 compilation process also relies on the Pcre-devel software package, which needs to be installed beforehand. This package system CD comes with it, so find and install it.

Reference command:

#yum install-y Pcre-devel


2. Compile and install httpd-2.4.6

First download httpd-2.4.6 to local

# Tar XF httpd-2.4.6.tar.bz2# cd httpd-2.4.6#./configure--prefix=/usr/local/apache--SYSCONFDIR=/ETC/HTTPD-- 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


3. Modify the main configuration file of httpd and set the path of its PID file.


To edit the/etc/httpd/httpd.conf, add the following line:

Pidfile "/var/run/httpd.pid"


4, provide SYSV service script/etc/rc.d/init.d/httpd, the content is as follows:

#!/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/functionsif [ -f /etc/sysconfig/httpd ]; then         . /etc/sysconfig/httpdfi# 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/apachectlhttpd=${httpd-/usr/local/apache/bin/httpd}prog=httpdpidfile=${pidfile-/var/run/ Httpd.pid}lockfile=${lockfile-/var/lock/subsys/httpd}retval=0start ()  {         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&Nbsp;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 1esacexit  $RETVAL

Then give execute permission for this script:

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

Join the Service list:

# chkconfig--add httpd

The next step is to start the service and test it.

#service httpd Start

Open the browser to access the IP address to see:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/3B/wKiom1PGglPQ1gMLAAAbzGWGKpQ577.jpg "title=" 1.png " alt= "Wkiom1pgglpq1gmlaaabzgwgkpq577.jpg"/>


Second, installation mysql-5.5.33


1. Prepare the file system for data storage


Create a new logical volume and mount it to a specific directory. The process is no longer given here.

This assumes that the mounted directory of its logical volume is/mydata, and then needs to create the/mydata/data directory as the storage directory for MySQL data.


2. The new user runs the process in a secure manner:

# 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.5.33


First download the platform corresponding to the MySQL version to the local, here is the 64-bit platform, therefore, the choice is mysql-5.5.33-linux2.6-x86_64.tar.gz.

# tar XF mysql-5.5.33-linux2.6-x86_64.tar.gz-c/usr/local# cd/usr/local/# ln-sv mysql-5.5.33-linux2.6-x86_64 mysql# CD MySQL # chown-r mysql:mysql. # scripts/mysql_install_db--user=mysql--datadir=/mydata/data# chown-r root.


4. Provide the main configuration file for MySQL:

# cd/usr/local/mysql# CP support-files/my-large.cnf/etc/my.cnf


and modify the value of thread_concurrency in this file to multiply your number of CPUs by 2, for example using the following line:

Thread_concurrency = 4

Also add the following line to specify where the MySQL data file will be stored:

DataDir =/mydata/data


5. Provide SYSV service script for MySQL:

# cd/usr/local/mysql# CP support-files/mysql.server/etc/rc.d/init.d/mysqld# chmod +x/etc/rc.d/init.d/mysqld

Add to Service list:

# chkconfig--add mysqld# chkconfig mysqld on

6. Create the mysql.sh under/ETC/PROFILE.D and modify the content:

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/3C/wKiom1PGlb2Spv3nAAGxBSysU6g386.jpg "title=" 20.png "alt=" Wkiom1pglb2spv3naagxbsysu6g386.jpg "/>


In order to use the MySQL installation to conform to the system usage specification and export its development components to the system, the following steps are required:

7, output the MySQL man manual to the man command to find the path:

To edit the/etc/man.config, add the following line:

Manpath/usr/local/mysql/man

8, output MySQL header file to the System header file path/usr/include:

This can be achieved by simply creating a link:

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

9. Output MySQL library file to the system library to find the path:

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

The system is then re-loaded into the system library:

# Ldconfig


Third, compile and install php-5.4.19

1, to resolve the dependency relationship:

# yum Install libxml2# yum install libxml2-devel-y


2. Compile and install php-5.4.19

Download the source package to your local directory first.

# Tar XF php-5.4.19.tar.bz2# cd php-5.4.19#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql-- With-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config--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


Description

1. In order to support the two mpm of the Apache worker or event, the--ENABLE-MAINTAINER-ZTS option is used at compile time.

2, if you use PHP5.3 or above, in order to link the MySQL database, you can specify MYSQLND, so you do not need to install the MySQL or MySQL development package. MYSQLND is available from PHP 5.3 and can be bound to it at compile time (instead of relying on the specific MySQL client library bindings), but it is the default setting starting with PHP 5.4. The command is:

#./configure--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd



Then start the installation:

# make# make test# make Intall

To provide a configuration file for PHP:

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


3, edit Apache configuration file httpd.conf, with Apache support PHP

# vim/etc/httpd/httpd.conf

1, add the following two lines

AddType application/x-httpd-php. php

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

2. Locate to DirectoryIndex index.html

Modified to:

DirectoryIndex index.php index.html

Then restart httpd, or let it reload the configuration file to test if PHP is already working.


4. Test, create the index.php file under/usr/local/apache/htdocs, with the following contents:

<?php phpinfo ();?>

Open the test page from the browser as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/6B/wKioL1PHWb2xdvuJAAIiMC2v6ww139.jpg "title=" 2.png " alt= "Wkiol1phwb2xdvujaaiimc2v6ww139.jpg"/>


Iv. Install the XCache for PHP acceleration:


1. Installation

# Tar XF xcache-3.0.3.tar.gz# cd xcache-3.0.3#/usr/local/php/bin/phpize#./configure--enable-xcache--with-php-config =/usr/local/php/bin/php-config# make && make install

At the end of the installation, a line similar to the following appears:

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20100525/


2, edit php.ini, integrate PHP and XCache:


The sample configuration provided by XCache is first imported into the php.ini

# mkdir/etc/php.d# CP XCACHE.INI/ETC/PHP.D

Description: The Xcache.ini file is in the XCache source directory.


Next edit/etc/php.d/xcache.ini, locate the line that begins with extension, and modify it to the following line:

Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so


3. Test, at which time the previous test page is refreshed, where you can find the XCache option

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/6B/wKiom1PHWTWQlwssAAHP0-jY9Ac329.jpg "title=" 3.png " alt= "Wkiom1phwtwqlwssaahp0-jy9ac329.jpg"/>


This article is from the "xlows" blog, make sure to keep this source http://xlows.blog.51cto.com/5380484/1439445

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.