Detailed steps to build a LAMP environment in CentOS 6.5
1Confirm setupLAMPWhether the required environment has been installed:
[Root @ localhost ~] # Rpm-q make gcc-c ++ zlib-devel libtool-ltdl-devel bisonncurses-devel
Remarks:InstallLibpngRequiredZlib-devel
InstallPhpRequiredLibtool,Libtool-ltdl,Libtool-ltdl-devel
InstallMysqlRequiredBison,Ncurses-devel
2If not installedYumInstall:
[Root @ localhost ~] # Yum-y install make gcc-c ++ zlib-devel libtool-ltdllibtool-ltdl-devel bison ncurses-devel
3ViewHttpd,Mysql,PhpInstall or not:
[Root @ localhost ~] # Rpm-q httpd mysql php
Uninstall if installed:
[Root @ localhost ~] # Rpm-e httpd -- nodeps
[Root @ localhost ~] # Rpm-e mysql -- nodeps
[Root @ localhost ~] # Rpm-e php -- nodeps
Compilation and installation process introduction:
1) DecompressTar.gzZip package with a suffix:LAMPThe soft code file of each software required for Environment setup isTar.gzOr. TgzProvide us with a compressed package file, so we must decompress it and then unpackage it. The command is as follows:
Tar-zxvf * .tar.gz
2) InLinuxInstallation Process of the source code package in the system:LAMPAll the software required for Environment setup is used.CLanguage development, so the installation of source code files requires at least three steps: configuration, compilation, and installation
Configure (Configure), Compile (Make), Installation (Makeinstall)
4, Compilation and InstallationLibxml2
[Root @ localhostlinux] # tar-zxvf libxml2-2.6.30.tar.gz
[Root @ localhostlinux] # libxml2-2.6.30 cd
[Root@localhostlibxml2-2.6.30] #./configure -- prefix =/usr/local/libxml2
# Make
[Root@localhostlibxml2-2.6.30] # make install
5, Compilation and InstallationLibmcrypt
[Root @ localhostlinux] # tar-zxvf libmcrypt-2.5.8.tar.gz
[Root @ localhostlinux] # libmcrypt-2.5.8 cd
[Root@localhostlibmcrypt-2.5.8] #./configure -- prefix =/usr/local/libmcrypt
# Make
[Root@localhostlibmcrypt-2.5.8] # make install
6, Compilation and InstallationZlib
[Root @ localhostlinux] # tar-zxvf zlib-1.2.3.tar.gz
[Root @ localhostlinux] # zlib-1.2.3 cd
[Root@localhostzlib-1.2.3] # CFLAGS = "-O3-fPIC"./configure -- prefix =/usr/local/zlib/
(Use64The bitwise method is used for compilation)
# Make
[Root@localhostzlib-1.2.3] # make install
7, Compilation and InstallationLibpng
[Root @ localhostlinux] # tar-zxvf libpng-1.2.31.tar.gz
[Root @ localhostlinux] # libpng-1.2.31 cd
[Root@localhostlibpng-1.2.31] #./configure -- prefix =/usr/local/libpng \
> -- Enable-shared(Used to create a shared libraryGNUOfLibtool)
# Make
[Root@localhostlibpng-1.2.31] # make install
8, Compilation and InstallationJpeg
[Root @ localhostlinux] # tar-zxvf restart src.v6b.tar.gz
[Root @ localhostlinux] # jpeg-6b cd
[Root @ localhostjpeg-6b] # mkdir/usr/local/jpeg(CreateJpegSoftware Installation Directory)
[Root @ localhostjpeg-6b] # mkdir/usr/local/jpeg/bin(Create a directory for storing commands)
[Root @ localhostjpeg-6b] # mkdir/usr/local/jpeg/lib(CreateJpegLibrary file directory)
[Root @ localhostjpeg-6b] # mkdir/usr/local/jpeg/include(Create a directory for storing header files)
[Root @ localhostjpeg-6b] # mkdir-p/usr/local/jpeg/man/man1(Create a directory for storing the manual)
[Root @ localhostjpeg-6b] #./configure -- prefix =/usr/local/jpeg \
> -- Enable-shared \(Used to create a shared libraryGUNOfLibtool)
> -- Enable-static (Used to create a static libraryGUNOfLibtool)
[Root @ localhostjpeg-6b] # make
[Root @ localhostjpeg-6b] # make install
RunMakeIf the following error occurs:
./Libtool -- mode = compile gcc-O2-I.-c./jcapimin. c
Make:./libtool: Command notfound
Make: *** [jcapimin. lo] Error 127
Solution:
Installed by defaultLibtoolAndLibtool-ltdl-devel(See the process for help.2)
[Root @ localhostjpeg-6b] # find/-name config. sub
/Usr/share/libtool/config. sub
[Root @ localhostjpeg-6b] # find/-name config. guess
/Usr/share/libtool/config. guess
[Root @ localhostjpeg-6b] # cp-vRp/usr/share/libtool/config. sub.
[Root @ localhostjpeg-6b] # cp-vRp/usr/share/libtool/config. guess.
That isLibtoolThese two configuration files are overwritten.Jpeg-6bCorresponding file under the Directory
Make cleanTry againConfigure
9, Compilation and InstallationFreetype
[Root @ localhostlinux] # tar-zxvf freetype-2.3.5.tar.gz
[Root @ localhostlinux] # freetype-2.3.5 cd
[Root@localhostfreetype-2.3.5] #./configure -- prefix =/usr/local/freetype \
> -- Enable-shared(Used to create a shared libraryGUNOfLibtool)
# Make
[Root@localhostfreetype-2.3.5] # make install
10, Compilation and InstallationAutoconf
[Root @ localhostlinux] # tar-zxvf autoconf-2.61.tar.gz
[Root @ localhostlinux] # autoconf-2.61 cd
[Root@localhostautoconf-2.61] #./configure
# Make
[Root@localhostautoconf-2.61] # make install
11, Compilation and InstallationGD
[Root @ localhostlinux] # tar-zxvf gd-2.0.35.tar.gz
[Root @ localhostlinux] # gd-2.0.35 cd
[Root@localhostgd-2.0.35] #./configure -- prefix =/usr/local/gd \
> -- With-zlib =/usr/local/zlib /\(SpecifyZlibLibrary File Location)
> -- With-jpeg =/usr/local/jpeg /\(SpecifyJpegLibrary File Location)
> -- With-png =/usr/local/libpng /\(SpecifyPngLibrary File Location)
> -- With-freetype =/usr/local/freetype/(SpecifyFreetypePosition of the Library)
# Make
[Root@localhostgd-2.0.35] # make install
RunMakeIf the following error occurs:
Make [2]: *** [gd_png.lo] Error 1
Make [2]: Leaving directory '/usr/src/linux/gd-2.0.35'
Make [1]: *** [all-recursive] Error 1
Make [1]: Leaving directory '/usr/src/linux/gd-2.0.35'
Make: *** [all] Error 2
Solution:
[Root@localhostgd-2.0.35] # find/-name gd_png.c
/Usr/src/linux/gd-2.0.35/gd_png.c
[Root@localhostgd-2.0.35] # find/-name png. h
/Usr/local/libpng/include/png. h
[Root@localhostgd-2.0.35] # vi/usr/src/linux/gd-2.0.35/gd_png.c
Set# Include "png. h"
Change# Include "/usr/local/libpng/include/png. h"
12, Compilation and InstallationApache
[Root @ localhostlinux] # tar-zxvf httpd-2.2.9.tar.gz
[Root @ localhostlinux] # httpd-2.2.9 cd
[Root@localhosthttpd-2.2.9] #./configure -- prefix =/usr/local/apache \
> -- Enable-so \(Compiled with dynamic shared object)
> -- Enable-rewrite(Rule-basedURLControl)
# Make
[Root@localhosthttpd-2.2.9] # make install
SetApacheAdd to start Supervisor
# Cp-vRp/usr/local/apache/bin/apachectl/etc/init. d/httpd
# Chmod + x/etc/init. d/httpd
AddApacheService Catalog
# Chkconfig -- add httpd
[Root@localhosthttpd-2.2.9] # chkconfig -- level 2345 httpd on
[Root@localhosthttpd-2.2.9] # service httpd start
When starting the service,If the following error occurs:
Httpd: cocould not reliablydetermine the server's fully qualified domain name, using localhost. localdomainfor ServerName
Solution:
[Root@localhosthttpd-2.2.9] # vi/usr/local/apache/conf/httpd. conf
Add:ServerName localhost: 80
RunChkconfigHour,If the following error occurs:
Service httpd does not supportchkconfig
Solution:
[Root@localhosthttpd-2.2.9] # vi/etc/rc. d/init. d/httpd
Add
# Chkconfig: 2345 10 90
# Description: Activates/DeactivatesApache Web Server
Save and then executeChkconfig
13, Compilation and InstallationMysql(The latest version is required.CmakeCompile and install)
Compile and installCmake
[Root @ localhostlinux] # tar-zxvf cmake-2.8.7.tar.gz
[Root @ localhostlinux] # cmake-2.8.7 cd
[Root@localhostcmake-2.8.7] #./bootstrap
[Root@localhostcmake-2.8.7] # gmake
[Root@localhostcmake-2.8.7] # gmake install
Compile and installMySQL5.5.20
[Root@localhostcmake-2.8.7] # groupadd mysql
[Root@localhostcmake-2.8.7] # useradd-g mysql
[Root @ localhostlinux] # tar-zxvf mysql-5.5.15.tar.gz
[Root @ localhostlinux] # mysql-5.5.15 cd
[Root@localhostmysql-5.5.15] #
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \(Install the root directory)
>-DMYSQL_UNIX_ADDR =/usr/local/mysql/data/mysql. sock \(UNIX socketFile)
>-DDEFAULT_CHARSET = utf8 \(Default Character Set)
>-DDEFAULT_COLLATION = utf8_general_ci \(Default encoding)
>-DWITH_EXTRA_CHARSETS = utf8, gbk \(Additional encoding)
>-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1 \(EnablePERFSCHEMAEngine Support)
>-DWITH_FEDERATED_STORAGE_ENGINE = 1 \(EnableFEDERATEDEngine Support)
>-DWITH_PARTITION_STORAGE_ENGINE = 1 \(EnablePARTITIONEngine Support)
>-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \(EnableARCHIVEEngine Support)
>-DWITH_READLINE = 1 \(UseReadlineFunction)
>-DMYSQL_DATADIR =/usr/local/mysql/data \(Database Data Directory)
>-DMYSQL_TCP_PORT = 3306(TCP/IPPort)
# Make
[Root@localhostmysql-5.5.15] # make install
[Root@localhostmysql-5.5.15] # cp-vRp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf
Modify the configuration file Lifecycle
[Root@localhostmysql-5.5.15] # vi/etc/my. cnf
Basedir =/usr/local/mysql
Datadir =/usr/local/mysql/data
Log-error =/usr/local/mysql/data/error. log
Pid-file =/usr/local/mysql/data/mysql. pid
Initialize database file metadata
[Root@localhostmysql-5.5.15] #/usr/local/mysql/scripts/mysql_install_db \
> -- Defaults-flie =/etc/my. cnf \
> -- Basedir =/usr/local/mysql /\
> -- Datadir =/usr/local/mysql/data \
> -- Pid-file =/usr/local/mysql/data/mysql. pid \
> -- User = mysql
Permission settings
[Root @ localhostmysql] # chown-R root.
[Root @ localhostmysql] # chown-R mysql data
[Root @ localhostmysql] # chgrp-R mysql.
SetMysqlAdd to start Supervisor
[Root @ localhostmysql] # cp-vRp support-files/mysql. server/etc/init. d/mysqld
[Root @ localhostmysql] # chmod + x/etc/init. d/mysqld
AddMysqlService Catalog
[Root @ localhostmysql] # chkconfig -- add mysqld
[Root @ localhostmysql] # chkconfig -- level 345 mysqld on
[Root @ localhostmysql] # service mysqld start
ConfigurationMysqlBytes
[Root @ localhostmysql] # bin/mysql
Mysql> deletefrom mysql. user where Host! = 'Localhost ';(Only accounts that allow local logon are left)
Mysql> flushprivileges;(Refresh the authorization table)
Mysql> setpassword for 'root' @ 'localhost' = password ('123 ');(Set User Password)
Mysql> exit
[Root @ localhostmysql] # bin/mysql-h localhost-u root-p123456(LoginMysql)
14, Compilation and InstallationPhp
[Root @ localhostlinux] # tar-zxvf php-5.3.19.tar.gz
[Root @ localhostlinux] # php-5.3.19 cd
[Root@localhostphp-5.3.19] #./configure -- prefix =/usr/local/php \
> -- With-apxs2 =/usr/local/apache/bin/apxs \
> -- With-mysql =/usr/local/mysql /\
> -- With-libxml-dir =/usr/local/libxml2 /\
> -- With-png-dir =/usr/local/libpng /\
> -- With-jpeg-dir =/usr/local/jpeg /\
> -- With-freetype-dir =/usr/local/freetype /\
> -- With-gd =/usr/local/gd /\
> -- With-mcrypt =/usr/local/libmcrypt /\
> -- With-mysqli =/usr/local/mysql/bin/mysql_config \
> -- Enable-soap \(Variable ActivationSOAPAndWeb servicesSupported)
> -- Enable-mbstring = all \(Supports multi-byte strings)
> -- Enable-sockets (Variable ActivationSocketCommunication features)
# Make
[Root@localhostphp-5.3.19] # make install
# Cp-vRp php. ini-development/etc/php. ini
[Root@localhostphp-5.3.19] # vi/usr/local/apache/conf/httpd. conf
Add:
AddType application/x-httpd-php. php
A [root@localhostphp-5.3.19] # service httpd stop
[Root@localhostphp-5.3.19] # service httpd start
[Root@localhostphp-5.3.19] # vi/usr/local/apache/htdocs/phpinfo. php
The added content is:
<? Php
Phpinfo ();
?>
Open a browser to access,IfPHPVersion page,And installed successfully.