Detailed steps for building an LAMP environment under 64 bit CentOS 6.0

  • 2020-05-09 19:43:22
  • OfStack

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

[root@centos6 ~]# rpm -q make gcc gcc-c++   zlib-devel   libaio Note: zlib-devel is required to install libpng                         libaio is required to install mysql 2. If not, install yum [root@centos6 ~]# yum install make gcc gcc-c++   zlib-devel libaio -y 3. Since you want to use compile and install, check whether httpd, mysql and php are installed, and if so, uninstall [root@centos6 ~]# rpm -q httpd mysql php 4. Compile and install libxml2 Note: libxml2 is a parser for xml in c language. It not only supports c language, but also supports bindings for 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 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 6. Compile and install zlib Note: zlib is a library that provides 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 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 (build for manual directory) [root@centos6 jpeg-8c]#  . / configure -- -- prefix = / usr local/jpeg / - enable - shared - enable - static (the use of Shared libraries GNU libtool and 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             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 you are prompted service   httpd   does not support chkconfig error Solution: edit/etc/rc d/init d/httpd line 2 to join to the document                     #chkconfig:2345   10 90                     #description:Activates/Deactivates Apache Web Server [root@centos6 ~]# chkconfig --level 2345 httpd on [root@centos6 LAMP]# service httpd restart Another way to start apache automatically after starting: Modify /etc/ rc.local # vim /etc/rc.local Added in the file/usr/local/apache bin/apachectl start 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 mysql user and assign the user to 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 all user groups in this directory to mysql user groups) [root @centos6 mysql]#./scripts/mysql_install_db --user=mysql (specify database permissions for 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] [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 root user login mysql password) [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) 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 > (successfully logged on 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 to change register_globals=Off to on mode and the time format to local 15.             changes the configuration file of apache for the purpose of parsing 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 above green content to indicate that the php file can be parsed in the apache service Next to check apache php dynamic link library files, generated directory in the directory/usr local/apache/modules, find the existence of   libphp5. so file 16,           validation           [root@centos6 ~]# vim /usr/local/apache/htdocs/index.php         < ?php       echo phpinfo(); ? > Upon verification at the customer service side, the following figure appears to indicate that the php setup was successful

Related articles: