64-bit CentOS 6.0 to build the lamp environment detailed steps _linux

Source: Internet
Author: User
Tags chmod install php mkdir

1 . Confirm that the environment required to build the lamp has been installed

[ROOT@CENTOS6 ~]# rpm-q make gcc gcc-c++ zlib-devel Libaio
Note: installation libpng need zlib-devel
need Libaio When installing MySQL
2, if not installed then Yum installation
[ROOT@CENTOS6 ~]# yum install make gcc gcc-c++ zlib-devel libaio-y
3, because to use the compilation installation, so see httpd, MySQL, PHP is installed, if the installation is uninstalled
[Root@centos6 ~]# rpm-q httpd mysql PHP
4. Compile and install LIBXML2
Note: LIBXML2 is an XML C language parser that supports not only C but also the binding of C + +, PHP, Pascal, Ruby, Tcl and other languages.
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF libxml2-2.7.8.tar.gz
[Root@centos6 lamp]# CD./libxml2-2.7.8
[Root@centos6 libxml2-2.7.8]#./configure--prefix=/usr/local/libxml2/
[ROOT@CENTOS6 libxml2-2.7.8]# Make;make Install
5. Compile and install Libmcrypt
Note:libmcrypt is a cryptographic algorithm extension library. Supports DES, 3DES, RIJNDAEL, Twofish, Idea, GOST, CAST-256, Arcfour, Serpent, safer+, and other algorithms.
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF libmcrypt-2.5.8.tar.gz
[Root@centos6 lamp]# CD./libmcrypt-2.5.8
[Root@centos6 libmcrypt-2.5.8]#./configure--prefix=/usr/local/libmcrypt/
[ROOT@CENTOS6 libmcrypt-2.5.8]# Make;make Install
6. Compile and install Zlib
Note:zlib is a function library for data compression
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF zlib-1.2.5.tar.gz
[Root@centos6 lamp]# CD./zlib-1.2.5
[Root@centos6 zlib-1.2.5]#./configure--prefix=/usr/local/zlib/
[Root@centos6 zlib-1.2.5]# make; Make install
7. Compile and install libpng
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF libpng-1.5.4.tar.gz
[Root@centos6 lamp]# CD./libpng-1.5.4
[Root@centos6 libpng-1.5.4]#
./configure--prefix=/usr/local/libpng/--enable-shared
[Root@centos6 libpng-1.5.4]# make; Make install
8. Compile and install JPEG
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF jpegsrc.v8c.tar.gz
[Root@centos6 lamp]# CD./jpeg-8c/
[root@centos6 jpeg-8c]# mkdir/usr/local/jpeg/ ( Create the installation directory for the JPEG software)
[root@centos6 jpeg-8c]# mkdir/usr/local/jpeg/bin/ (Create a directory that holds the command)
[root@centos6 jpeg-8c]# mkdir/usr/local/jpeg/lib/ (Create the directory where the JPEG library files are located)
[root@centos6 jpeg-8c]# mkdir/usr/local/jpeg/include/ (Create a storage header file directory)
[root@centos6 jpeg-8c]# mkdir-p/usr/local/jpeg/man/man1 (set up a directory for storing manuals)
[Root@centos6 jpeg-8c]#
./configure--prefix=/usr/local/jpeg/--enable-shared--enable-static ( build shared libraries using GNU Libtool and static libraries using the GNU Libtool)
[Root@centos6 jpeg-8c]# make; Make install
9. Compile and install FreeType
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF freetype-2.4.6.tar.gz
[Root@centos6 lamp]# CD./freetype-2.4.6
[Root@centos6 freetype-2.4.6]#
./configure--prefix=/usr/local/freetype/--enable-shared
[Root@centos6 freetype-2.4.6]# make, make install
10. Compile and install autoconf
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF autoconf-2.68.tar.gz
[Root@centos6 lamp]# CD./autoconf-2.68
[Root@centos6 autoconf-2.68]#./configure
[Root@centos6 autoconf-2.68]# make; Make install
11. Compile and install GD
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF gd-2.0.35.tar.gz
[Root@centos6 lamp]# CD./gd-2.0.35
[Root@centos6 gd-2.0.35]#
./configure--prefix=/usr/local/gd/--with-zlib=/usr/local/zlib/--with-jpeg=/usr/local/jpeg/--with-png=/usr/ local/libpng/--with-freetype=/usr/local/freetype/
[Root@centos6 gd-2.0.35]# make; Make install
12. install Apache
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF httpd-2.2.19.tar.gz
[Root@centos6 lamp]# CD./httpd-2.2.19
[Root@centos6 httpd-2.2.19]#
./configure--prefix=/usr/local/apache/--enable-so--enable-rewrite
[Root@centos6 httpd-2.2.19]# make; Make install
[Root@centos6 lamp]#/usr/local/apache/bin/apachectl start
[Root@centos6 lamp]#
Cp/usr/local/apache/bin/apachectl/etc/init.d/httpd
[Root@centos6 lamp]# chmod +x/etc/init.d/httpd
[Root@centos6 ~]# chkconfig--add httpd
Note: If prompted Service httpd does not support Chkconfig Error
Workaround: Edit/ etc /rc.d/init.d/httpd in the second line of the file, add
#chkconfig: 2345 Ten
#description: Activates /deactivates Apache Web Server
[Root@centos6 ~]# chkconfig--level 2345 httpd on
[ROOT@CENTOS6 lamp]# Service httpd restart
Another way to boot up Apache automatically:
modifying/etc/rc.local files
# vim/etc/rc.local
Add/usr/local/apache/bin/apachectl start to File
13, compile and install MySQL
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF mysql-5.5.15-linux2.6-x86_64.tar.gz
[Root@centos6 lamp]# CD./mysql-5.5.15-linux2.6-x86_64
[Root@centos6 mysql-5.5.15-linux2.6-x86_64]# Groupadd MySQL
[ROOT@CENTOS6 mysql-5.5.15-linux2.6-x86_64]# useradd-r-g MySQL MySQL (Create the MySQL user and assign the user to the MySQL group)
[Root@centos6 mysql-5.5.15-linux2.6-x86_64]# cd/usr/local/
[Root@centos6 local]# ln-s/tmp/lamp/mysql-5.5.15-linux2.6-x86_64 MySQL
[Root@centos6 local]# CD./mysql/
[root@centos6 mysql]# chown-r MySQL. (change all user permissions for this directory to MySQL users)
[root@centos6 mysql]# chgrp-r MySQL. (change the user group for this directory to the MySQL user group)
[Root@centos6 mysql]#./scripts/mysql_install_db--user=mysql (Specify database usage permissions for MySQL directory as MySQL)
[Root@centos6 mysql]# chown-r root.
[ROOT@CENTOS6 mysql]# chown-r MySQL Data
[ROOT@CENTOS6 mysql]# CP support-files/my-medium.cnf/etc/my.cnf (Copy the configuration file under the current directory to the system configuration file and rename it to my.cnf)
[ROOT@CENTOS6 mysql]# CP Support-files/mysql.server/etc/init.d/mysqld
[Root@centos6 mysql]# chmod +x/etc/init.d/mysqld
[Root@centos6 mysql]# chkconfig--add mysqld
[Root@centos6 mysql]# chkconfig--level 345 mysqld on
[ROOT@CENTOS6 mysql]# Service mysqld Restart
[Root@centos6 mysql]#
/usr/local/mysql/bin/mysqladmin-u root password ' 123456 ' (Set the password for root user login to MySQL)
[root@centos6 mysql]#/usr/local/mysql/bin/mysql-u root–p (Enter and access MySQL data)
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or G.
Your MySQL Connection ID is 2
Server Version:5.5.15-log MySQL Community Server (GPL)
Copyright (c), the Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.
Type ' help, ' or ' h ' for help. Type ' C ' to clear the current input statement.
Mysql> (successfully login MySQL)
14. compile and install PHP
[Root@centos6 lamp]# pwd
/tmp/lamp
[Root@centos6 lamp]# TAR-ZXVF php-5.3.7.tar.gz
[Root@centos6 lamp]# CD./php-5.3.7
[Root@centos6 php-5.3.7]#
./configure--prefix=/usr/local/php/--with-apxs2=/usr/local/apache/bin/apxs--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2 /--with-jpeg-dir=/usr/local/jpeg/--with-freetype-dir=/usr/local/freetype/--with-gd-dir=/usr/local/gd/-- With-zlib-dir=/usr/local/zlib/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_ Config--enable-soap--enable-mbstring=all--enable-sockets
[Root@centos6 php-5.3.7]# make; Make install
[Root@centos6 php-5.3.7]#
CP Php.ini-development/usr/local/php/lib/php.ini
#vim/usr/local/php/lib/php.ini
Here you need tochange register_globals = off to on mode and time format to local
15, change the Apache configuration file, to resolve the purpose of the PHP file
[root@centos6 ~]# vim/usr/local/apache/conf/httpd.conf
AddType application/x-compress. Z
AddType application/x-gzip. GZ tgz
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps
Add the green content above to indicate that the Apache service can parse PHP format files
Next to check the Apache directory generated PHP dynamic Connection library files, in the directory /usr/local/apache/modules, to find whether there are libphp5.so files
16. Verify
[root@centos6 ~]# vim/usr/local/apache/htdocs/index.php
Add content to
<?php
Echo Phpinfo ();
?>
In the customer service side verification, the following diagram shows that PHP built successfully
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.