PHP-detailed steps for building a LAMP environment under CentOS65

Source: Internet
Author: User
Tags fully qualified domain name
: This article describes how to set up a LAMP environment in CentOS65. For more information about PHP tutorials, see.
Reprinted please indicate the source: http://blog.csdn.net/l1028386804/article/details/48551221
1. check whether the environment required to build LAMP has been installed:
[root@localhost ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel
Note: zlib-devel is required for libpng installation.
Libtool, libtool-ltdl, and libtool-ltdl-devel are required for php installation.
Install mysql with bison, ncurses-devel2, and yum if not:
[root@localhost~]#yum -y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel bison ncurses-devel
3. check whether httpd, mysql, and php are installed as needed:
[root@localhost ~]#rpm -q httpd mysql php
Uninstall the SDK if it is 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. decompress a compressed package with the extension tar.gz: the soft code file for each software built in lampenvironment is a compressed package file provided by tar.gz or. tgz. Therefore, we must decompress it and decompress it. The command is as follows:
Tar-zxvf * .tar.gz
2) installation of source code packages in linux: the software required to build the LAMP environment is developed in C language. Therefore, the installation of source code files requires at least three steps: configuration, compilation, and installation.
Configure, make, and makeinstall)
4. Compile and install libxml2
[root@localhostlinux]# tar -zxvf libxml2-2.6.30.tar.gz [root@localhostlinux]# cd libxml2-2.6.30 [root@localhostlibxml2-2.6.30]# ./configure --prefix=/usr/local/libxml2[root@localhostlibxml2-2.6.30]# make[root@localhostlibxml2-2.6.30]# make install
5. Compile and install libmcrypt
[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz[root@localhostlinux]# cd libmcrypt-2.5.8[root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt [root@localhostlibmcrypt-2.5.8]# make[root@localhostlibmcrypt-2.5.8]# make install
6. Compile and install zlib
[Root @ localhostlinux] # tar-zxvf zlib-1.2.3.tar.gz [root @ localhostlinux] # cd zlib-1.2.3 [root@localhostzlib-1.2.3] # CFLAGS = "-O3-fPIC ". /configure -- prefix =/usr/local/zlib/(compiled with 64-bit methods) [root@localhostzlib-1.2.3] # make [root@localhostzlib-1.2.3] # make install
7. Compile and install libpng
[Root @ localhostlinux] # tar-zxvf libpng-1.2.31.tar.gz [root @ localhostlinux] # cd libpng-1.2.31 [root@localhostlibpng-1.2.31] #. /configure -- prefix =/usr/local/libpng \> -- enable-shared (build GNU libtool for shared libraries) [root@localhostlibpng-1.2.31] # make [root@localhostlibpng-1.2.31] # make install
8. Compile and install jpeg
[Root @ localhostlinux] # tar-zxvf unzip src.v6b.tar.gz [root @ localhostlinux] # cd jpeg-6b [root @ localhostjpeg-6b] # mkdir/usr/local/jpeg (create jpeg software installation directory) [root @ localhostjpeg-6b] # mkdir/usr/local/jpeg/bin (create a directory to store commands) [root @ localhostjpeg-6b] # mkdir/usr/local/jpeg/lib (create the directory where the jpeg library file is located) [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 manuals) [root @ localhostjpeg-6b] #. /configure -- prefix =/usr/local/jpeg \> -- enable-shared \ (create the libtool of the GUN used by the shared library)> -- enable-static (create the libtool of GUN used by the static library) [root @ localhostjpeg-6b] # make [root @ localhostjpeg-6b] # make install
If the following error occurs during make execution:
./Libtool -- mode = compile gcc-O2-I.-c./jcapimin. c
Make:./libtool: Command notfound
Make: *** [jcapimin. lo] Error 127
Solution:
Libtool and libtool-ltdl-devel are installed by default. (See Process 2 for help)
[root@localhostjpeg-6b]# find / -name config.sub/usr/share/libtool/config/config.sub[root@localhostjpeg-6b]# find / -name config.guess/usr/share/libtool/config/config.guess[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.sub .[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.guess .
That is, the two configuration files in libtool are used to overwrite the corresponding files in the jpeg-6b directory.
Make clean and re-configure 9. Compile and install freetype
[Root @ localhostlinux] # tar-zxvf freetype-2.3.5.tar.gz [root @ localhostlinux] # cd freetype-2.3.5 [root@localhostfreetype-2.3.5] #. /configure -- prefix =/usr/local/freetype \> -- enable-shared (build the libtool of GUN used by the shared library) [root@localhostfreetype-2.3.5] # make [root@localhostfreetype-2.3.5] # make install
10. Compile and install autoconf
[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz[root@localhostlinux]# cd autoconf-2.61[root@localhostautoconf-2.61]# ./configure[root@localhostautoconf-2.61]# make[root@localhostautoconf-2.61]# make install
11. Compile and install GD
[Root @ localhostlinux] # tar-zxvf gd-2.0.35.tar.gz [root @ localhostlinux] # cd gd-2.0.35 [root@localhostgd-2.0.35] #. /configure -- prefix =/usr/local/gd \> -- with-zlib =/usr/local/zlib/\ (specify the zlib library file location)> -- with-jpeg =/usr/local/jpeg/\ (specify the location of the jpeg library file)> -- with-png =/usr/local/libpng/\ (specifies the location of the png library file)> -- with-freetype =/usr/local/freetype/(specifies the location of the freetype library) [root@localhostgd-2.0.35] # make [root@localhostgd-2.0.35] # make install
If the following error occurs during make execution:
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 will #Include"Png. h" #Include"/Usr/local/libpng/Include/Png. h"
12. Compile and install Apache
[Root @ localhostlinux] # tar-zxvf httpd-2.2.9.tar.gz [root @ localhostlinux] # cd httpd-2.2.9 [root@localhosthttpd-2.2.9] #./configure -- prefix =/usr/local/Apache\> -- Enable-so \ (dynamically shareObjectCompile)> -- enable-rewrite (rule-based URL control) [root@localhosthttpd-2.2.9] # make [root@localhosthttpd-2.2.9] # make installApacheAdd boot supervisor [root@localhosthttpd-2.2.9] # cp-vRp/usr/local/Apache/Bin/ApacheCtl/etc/init. d/httpd[ root@localhosthttpd-2.2.9] #Chmod+ Add x/etc/init. d/httpdApacheService Catalog [root@localhosthttpd-2.2.9] # chkconfig -- add httpd [root@localhosthttpd-2.2.9] # chkconfig -- level 2345 httpd on [root@localhosthttpd-2.2.9] # service httpd start
If the following error occurs when starting the service:
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
If the following error occurs during chkconfig execution:
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 run chkconfig.
13. Compile and install mysql (the latest version requires cmake compilation and installation). Compile and install cmake
[root@localhostlinux]# tar -zxvf cmake-2.8.7.tar.gz[root@localhostlinux]# cd cmake-2.8.7[root@localhostcmake-2.8.7]# ./bootstrap[root@localhostcmake-2.8.7]# gmake[root@localhostcmake-2.8.7]# gmake install
Compile and install MySQL5.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] # cd mysql-5.5.15 [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 socket file)>-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 \ (enable PERFSCHEMA engine support)>-DWITH_FEDERATED_STORAGE_ENGINE = 1 \ (enable FEDERATED engine support)> -DWITH_PARTITI (enabling PARTITION engine support)>-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \ (enabling ARCHIVE engine support)>-DWITH_READLINE = 1 \ (using the readline function)> -DMYSQL_DATADIR =/usr/local/mysql/data \ (database data directory)>-DMYSQL_TCP_PORT = 3306 (TCP/IP port) [root@localhostmysql-5.5.15] # 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 .
Add mysql to boot and start mysql
[root@localhostmysql]# cp -vRp support-files/mysql.server /etc/init.d/mysqld[root@localhostmysql]# chmod +x /etc/init.d/mysqld
Add a mysql service license
[root@localhostmysql]# chkconfig --add mysqld[root@localhostmysql]# chkconfig --level 345 mysqld on[root@localhostmysql]# service mysqld start
Configure mysql Connector
[Root @ localhostmysql] # bin/mysqlmysql> 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 ('000000'); (set the user password) mysql> exit [root @ localhostmysql] # bin/mysql-h localhost-u root-p123456 (log on to mysql)
14. Compile and install php
[Root @ localhostlinux] # tar-zxvf php-5.3.19.tar.gz [root @ localhostlinux] # cd php-5.3.19 [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 activation supported by SOAP and web services)> -- enable-mbstring = all \ (supports multi-byte strings)> -- enable-sockets (variables enable socket communication features) [root@localhostphp-5.3.19] # make [root@localhostphp-5.3.19] # make install [root@localhostphp-5.3.19] # 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
[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:
 
Open the browser to access the PHP version. if the PHP version interface is displayed and the installation is successful.

The above describes the detailed steps for building a LAMP environment under CentOS 65 of PHP, including some content, and hope to help those who are interested in PHP tutorials.

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.