PHP--centos 65 to build the lamp environment detailed steps

Source: Internet
Author: User
Tags phpinfo fully qualified domain name
Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/48551221

1, confirm that 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 required when installing libpng
Libtool, Libtool-ltdl, libtool-ltdl-devel are required to install PHP
Bison, ncurses-devel required when installing MySQL

2. Yum installation if not installed:

[root@localhost~] #yum-y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel Bison ncurses-devel

3, because to use the compilation installation, so check whether httpd, MySQL, PHP installed:

[root@localhost ~] #rpm-q httpd mysql PHP
If the installation is uninstalled:
[root@localhost ~] #rpm-e httpd--nodeps[root@localhost ~] #rpm-e mysql--nodeps[root@localhost ~] #rpm-e php--nodeps
The compile and install process describes:
1) Unzip the tar.gz as the suffix of the compression package: the lamp environment to build the required software for each soft code files, are provided to us by tar.gz or. tgz Package compressed files, so we have to unzip and unpack. The command is as follows:
TAR–ZXVF *.tar.gz
2) in the Linux system source code package installation process: Lamp environment to build the required software is developed using the C language, so install the source code files need to configure, compile and install the minimum three steps
Configuration (configure), compile (make), install (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 method) [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 (the GNU Libtool used to build the shared library) [ root@localhostlibpng-1.2.31]# make[root@localhostlibpng-1.2.31]# make Install

8. Compile and install JPEG

[root@localhostlinux]# tar-zxvf jpegsrc.v6b.tar.gz[root@localhostlinux]# CD jpeg-6b[root@localhostjpeg-6b]# mkdir/ Usr/local/jpeg                    (Create the installation directory for the JPEG software) [root@localhostjpeg-6b]# mkdir/usr/local/jpeg/bin            (Create directory to hold commands) [ root@localhostjpeg-6b]# mkdir/usr/local/jpeg/lib             (the directory where the JPEG library files are created) [root@localhostjpeg-6b]# mkdir/usr/local/ jpeg/include      (Create Storage header file directory) [root@localhostjpeg-6b]# mkdir-p/usr/local/jpeg/man/man1  (creating directory for storing manuals) [ root@localhostjpeg-6b]#./configure--prefix=/usr/local/jpeg \>--enable-shared \    (Build the libtool of the gun used in the shared library) >- -enable-static        (Libtool of the gun used to build the static library) [root@localhostjpeg-6b]# make[root@localhostjpeg-6b]# make install
when you execute make, the following error occurs:
./libtool--mode=compile gcc-o2-i. C./jcapimin.c
Make:./libtool:command NotFound
Make: * * * [Jcapimin.lo] Error 127
Workaround:
Libtool and Libtool-ltdl-devel are installed by default (see procedure 2 If you need 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 libtool inside the two configuration files to cover the jpeg-6b directory of the corresponding files
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    (Libtool of the 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/\      (Specifies the location of the zlib library file) >--with-jpeg=/usr/local /jpeg/\    (Specifies 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/     (Specify the location of the FreeType font library) [root@localhostgd-2.0.35]# make[root@localhostgd-2.0.35]# make install
When you execute make, 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
Workaround:
[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 Change #include "Png.h" to    #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 \       (compiled with dynamic shared object ) >--enable-rewrite  (rule-based URL manipulation) [root@localhosthttpd-2.2.9]# make[root@localhosthttpd-2.2.9]# make install will Apache Join boot ↓[root@localhosthttpd-2.2.9]# cp-vrp/usr/local/apache/bin/Apachechmod +x/etc/ INIT.D/HTTPD Add Apache service ↓[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
When you start the service, the following error occurs:
httpd:could not reliablydetermine the server ' s fully qualified domain name, using localhost.localdomainfor ServerName
Workaround:
[root@localhosthttpd-2.2.9]# vi/usr/local/Apache/conf/httpd.conf
Added on: ServerName localhost:80
When you execute Chkconfig, the following error occurs:
service httpd does not supportchkconfig

Workaround:

[root@localhosthttpd-2.2.9]# vi/etc/rc.d/init.d/httpd
On the second line of the file, add
#chkconfig: 2345 90#description:activates/deactivatesApache Web Server
Save and then execute Chkconfig

13, compile and install MySQL (the latest version requires CMake compilation installation)

Compiling and installing 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
Compiling and installing MySQL5.5.20
[root@localhostcmake-2.8.7]# groupadd mysql[root@localhostcmake-2.8.7]# useradd-g MySQL 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 \ (Installation root) >-dmysql_unix_addr=/usr/local/mysql/data/mysql.sock \ (UNIX Socke T 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 (Enable partition engine support) >-dwith_archive_storage_engine=1 \ (enable ARCHIVE engine support) >-dwith_readline=1 \ (use 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[r oot@localhostmysql-5.5.15]# cp-vrp/usr/local/mysql/sUpport-files/my-medium.cnf/etc/my.cnf 
Modify the configuration file ↓
[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
Initializing the database file ↓
[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 up ↓
chmod +x/etc/init.d/mysqld
Add MySQL service ↓
[root@localhostmysql]# chkconfig--add mysqld[root@localhostmysql]# chkconfig--level 345 mysqld on[ root@localhostmysql]# Service mysqld Start
Configure Mysql↓
[root@localhostmysql]# bin/mysqlmysql> deletefrom mysql.user where host!= ' localhost '; (only leave the account that allows the native login) mysql> flushprivileges;  (Refresh authorization form) mysql> SetPassword for ' root ' @ ' localhost ' =password (' 123456 ');  (set user password) mysql> exit[root@localhostmysql]# bin/mysql-h localhost-u root-p123456 (log in 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-activated SOAP and Web services support) >--enable-mbstring=all \    (Enable multibyte string support) >--enable-sockets                (variable activates socket communication feature) [ 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 on:
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
Add content to:
 
  
Open the browser to access, if the PHP version of the interface, and installation success.

The above describes the PHP--centos 65 to build the lamp environment detailed steps, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.