Centos6.0 -- lamp Environment Construction

Source: Internet
Author: User

1. Check whether the environment required to build LAMP has been installed.
[Root @ centos6 ~] # Rpm-q make gcc-c ++ zlib-devel libaio
Note: zlib-devel is required for libpng installation.
Libaio is required for mysql installation.
2. If not, install yum
[Root @ centos6 ~] # Yum install make gcc-c ++ zlib-devel libaio-y
3. Check whether httpd, mysql, and php are installed because you need to use compilation and installation. If installation is required, uninstall
[Root @ centos6 ~] # Rpm-q httpd mysql php
4. Compile and install libxml2
Note: libxml2 is an xml c-language parser. It not only supports c language, but also supports binding 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 an extended library of encryption algorithms. 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 restart src.v8c.tar.gz
[Root @ centos6 LAMP] # cd./jpeg-8c/
[Root @ centos6 jpeg-8c] # mkdir/usr/local/jpeg/(create the installation directory for jpeg software)
[Root @ centos6 jpeg-8c] # mkdir/usr/local/jpeg/bin/(create a directory for storing commands)
[Root @ centos6 jpeg-8c] # mkdir/usr/local/jpeg/lib/(create the directory where the jpeg library file is located)
[Root @ centos6 jpeg-8c] # mkdir/usr/local/jpeg/include/(create a directory for storing header files)
[Root @ centos6 jpeg-8c] # mkdir-p/usr/local/jpeg/man/man1 (create a directory for storing manuals)
[Root @ centos6 jpeg-8c] #
./Configure -- prefix =/usr/local/jpeg/-- enable-shared -- enable-static (create the GNU libtool used by the shared library and the GNU libtool used by the static library)
[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 the error message "service httpd does not support chkconfig" is displayed
Solution: edit/etc/rc. d/init. d/httpd and add
# Chkconfig: 2345 10 90
# Description: Activates/Deactivates Apache Web Server
[Root @ centos6 ~] # Chkconfig -- level 2345 httpd on
[Root @ centos6 LAMP] # service httpd restart
Another method for automatically starting apache upon startup:
Modify the/etc/rc. local file
# Vim/etc/rc. local
Add/usr/local/apache/bin/apachectl start to the 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 (create a mysql user and specify the user to a 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 in this directory to mysql Users)
[Root @ centos6 mysql] # chgrp-R mysql. (change all user groups in this directory to the mysql user group)
[Root @ centos6 mysql] #./scripts/mysql_install_db -- user = mysql (specify the database permission of the 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 in the current directory to the system configuration file and rename it 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 '000000' (set the password for the root user to log on to mysql)
[Root @ centos6 mysql] #/usr/local/mysql/bin/mysql-u root-p (access 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) 2000,201 0, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> (successfully logging on to 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-mysil =/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
// Change register_globals = Off TO on mode, and change the time format to local
15. Change the apache configuration file to parse 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, indicating that php files can be parsed in apache.
Next, check the php dynamic connection library file generated under the apache directory and find whether the libphp5.so file exists in the directory/usr/local/apache/modules.
16. Verification
[Root @ centos6 ~] # Vim/usr/local/apache/htdocs/index. php
Add content
<? Php
Echo phpinfo ();
?>
Verify on the client, indicating that php is successfully built

Author: "Darren-pan"

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.