Detailed steps for setting up LAMP environment under 64 bit CentOS 6.0

  • 2020-05-06 12:10:17
  • OfStack

1. Confirm whether the environment required for setting up LAMP has been installed with

[root@centos6 ~]# rpm -q make gcc gcc-c++   zlib-devel   libaio remarks: libpng requires zlib devel                 mysql libaio 2. If it is not installed, yum shall install [root@centos6 ~]# yum install make gcc gcc-c++   zlib-devel libaio -y 3. Since you are going to use compile and install, check whether httpd, mysql, php are installed, and if so, uninstall [root@centos6 ~]# rpm -q httpd mysql php Note: libxml2 is a parser for xml c language, which not only supports c language, but also supports c++, php, Pascal, Ruby, Tcl and other languages /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 Note: libmcrypt is an encryption algorithm extension library. Support for 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 Note: zlib is a library that provides [root@centos6 LAMP]# pwd for data compression /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 - 8 c] # mkdir/usr/local/jpeg/ (create jpeg software installation directory) [root @ centos6 jpeg - 8 c] # mkdir/usr local/jpeg/bin/ Deposit (create command directory) [root @ centos6 jpeg - 8 c] # mkdir/usr local/jpeg lib/ (create jpeg library file directory) [root @ centos6 jpeg - 8 c] # mkdir / usr/local/jpeg include/ deposit (create a header file directory) [root @ centos6 jpeg - 8 c] # mkdir - p/usr/local/jpeg man/man1 [root@centos6 jpeg-8c]# (build for manual directory)  . / configure -- -- prefix = / usr local/jpeg / - enable - shared - enable - static ( GNU libtool and the use of a Shared library static library use 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   httpd does not chkconfig error solution: Edit/ etc /rc d/init d/httpd in file the second line to join                     #chkconfig: 2345   10 90                     #description: Activates /Deactivates Apache Web Server [root@centos6 ~]# chkconfig --level 2345 httpd on [root@centos6 LAMP]# service httpd restart boot automatically starts apache another method: modify /etc/ rc.local file # vim /etc/rc.local added in the file/usr/local/apache bin/apachectl start 13,             mysql [root@centos6 LAMP]# pwd compile installation /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 [root@centos6 local]# ln -s /tmp/LAMP/mysql-5.5.15-linux2.6-x86_64 mysql [root@centos6 local]# cd ./mysql/ [root@centos6 mysql [root@centos6 mysql]#./scripts/mysql_install_db --user=mysql [root@centos6 mysql]# chown -R mysql data [root@centos6 mysql [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 root user login mysql password) [root @ centos6 mysql] # / usr/local/mysql/bin/mysql - u root � p Enter password: (enter and access mysql data) 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, 2010, 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 >           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 we need to change register_globals=Off to on mode, and change the time format to local 15,           to apache configuration file to achieve the purpose of php file parsing         [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 green content above, said apache services can parse php format file to check next apache php dynamic link library files, generated directory in the directory/usr local/apache/modules, find the existence of   libphp5. 16 so file,                   [root@centos6 ~]# vim /usr/local/apache/htdocs/index.php   validation         add < ?php       echo phpinfo(); ? > After verification on the customer service side, the following figure appears to show that php has been successfully set up