Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build LAMP environment under 64-bit CentOS6.0

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "how to build LAMP environment under 64-bit CentOS6.0". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to build LAMP environment under 64-bit CentOS6.0" can help you solve your doubts.

1. Confirm whether the environment needed to build 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. Install yum if it is not installed

[root@centos6 ~] # yum install make gcc gcc-c++ zlib-devel libaio-y

3. Since you are going to use compilation and installation, check whether httpd, mysql and php are installed, and if so, uninstall them

[root@centos6 ~] # rpm-q httpd mysql php

4. Compile and install libxml2

Note: libxml2 is a parser for c language of xml, which not only supports c language, but also supports 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 an extended library of encryption algorithms. Support 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 of jpeg software)

[root@centos6 jpeg-8c] # mkdir / usr/local/jpeg/bin/ (create a directory where commands are stored)

[root@centos6 jpeg-8c] # mkdir / usr/local/jpeg/lib/ (the directory where the jpeg library file is created)

[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 to store the manual)

[root@centos6 jpeg-8c] #

. / configure-- prefix=/usr/local/jpeg/-- enable-shared-- enable-static (libtool of gnu used to build shared libraries and libtool of gnu used by static libraries)

[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 a service httpd does not support chkconfig error is prompted

Solution: edit / etc/rc.d/init.d/httpd add in the second line of the file

# 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 boot apache automatically:

Modify / 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 mysql (create a 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 rights in this directory to mysql)

[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 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 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 users to log in 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) 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 > (log in to mysql successfully)

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

/ / you need to change register_globals=off to on mode and change the time format to local.

15. Change the configuration file of apache 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 above green content to indicate that the php format file can be parsed in the apache service

Next, check the php dynamic link library file generated in the apache directory, and find out 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 as

After reading this, the article "how to build a LAMP environment under 64-bit CentOS6.0" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the article, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report