At that time we were ready to do a project, so I set up a lamp server, direct yum Install all the files, because CentOS is a relatively stable system, so it all the software above is not up-to-date, Apache is 2.2.15 version, PHP is 5.3.3,mysql is. 1.69. Results found page prompt error, hint what content I forgot, anyway put to local there is no problem, and later found is due to thinkphp framework, some grammar does not support php5.4 below, so decided to upgrade PHP, Is the painful process began!!!!
The first thought of the method is to change the source, to CentOS source, the server is 6.3 version, first replaced 163 of the source, and later changed the source of Zhong Ke, found all the same, yum info PHP is 5.3.3, later decided to install the source code PHP, but later found that the compilation must be added to the Apache and MySQL installation directory, because it is the Yum installed Apache and MySQL, no way to add directories, so decided to recompile all!!! OK, first the source!
Uninstalling the AMP software installed with yum or rpm
Before compiling and installing lamp, first uninstall the existing RPM package.
RPM-E httpd
RPM-E MySQL
Rpm-e PHP
Yum-y Remove httpd
Yum-y Remove PHP
yum-y Remove Mysql-server MySQL
Yum-y Remove Php-mysql
Disable SELinux
SELinux may cause the compilation installation to fail, we disable it first.
Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config//permanently disabled, requires reboot to take effect
Setenforce 0//temporary disable, no restart required
Yum Install the necessary tools
1. Install the compilation tool gcc Gcc-c++make automake autoconf kernel-devel
2, the installation of PHP required dependencies, such as Libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel
Yum-y install gcc gcc-c++ make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpe G-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file Bison patch Mlocate Flex diffutils ReadLine -devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel
Download the required source code
apache:http://httpd.apache.org/
mysql:http://mysql.com/downloads/mysql/
php:http://php.net/downloads.php
phpmyadmin:http://www.phpmyadmin.net/home_page/downloads.php
The version we have chosen here is: apache-2.2.22,mysql-5.1.62,php-5.2.17,phpmyadmin-3.4.10.2
Cd/tmp
Wget-c http://apache.ziply.com//httpd/httpd-2.2.22.tar.gz
Wget-c http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.64.tar.gz/from/http://mysql.he.net/
Wget-c Http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror
Wget-c http://iweb.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.10.2/phpMyAdmin-3.4.10.2-all-languages.tar.gz
Tar xzf httpd-2.2.22.tar.gz
Tar xzf mysql-5.1.62.tar.gz
Tar xzf php-5.2.17.tar.gz
Tar xzf phpmyadmin-3.4.10.2-all-languages.tar.gz
Installing apache2.2.22
cd/tmp/httpd-2.2.22
./configure--prefix=/usr/local/apache--with-included-apr--enable-so--enable-deflate=shared--enable-expires= Shared--enable-headers=shared--enable-rewrite=shared--enable-static-support
Make
Make install
Explanation of compilation parameters:
--prefix=/usr/local/apache: Specifying the installation directory
--WITH-INCLUDED-APR: Enforces the APR version that is bound in the current source code at compile time
--ENABLE-SO: Allows the runtime to load the DSO module
--enable-deflate=shared: Compiling the Deflate module as DSO
--enable-expires=shared: Compiling the Expires module as DSO
--enable-headers=shared: Compiling the Headers module as DSO
--enable-rewrite=shared: Compiling the rewrite module as DSO
--enable-static-support: Compile all binary support programs with a static connection (by default, dynamic connection)
More detailed explanation of compilation parameters: Http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html
CP build/rpm/httpd.init/etc/init.d/httpd//Use init script to manage httpd
chmod 755/etc/init.d/httpd//Increase execution privileges
Chkconfig--add httpd//Add httpd to service item
Chkconfig httpd on//Set boot up
ln-fs/usr/local/apache//etc/httpd
Ln-fs/usr/local/apache/bin/httpd/usr/sbin/httpd
Ln-fs/usr/local/apache/bin/apachectl/usr/sbin/apachectl
LN-FS/USR/LOCAL/APACHE/LOGS/VAR/LOG/HTTPD//Set soft links to fit init script
Installing mysql5.1.62
Groupadd MySQL
useradd-g MySQL MySQL
cd/tmp/mysql-5.1.62
./configure--prefix=/usr/local/mysql/--localstatedir=/usr/local/mysql/data--without-debug-- With-unix-socket-path=/tmp/mysql.sock--with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static-- Enable-assembler--with-extra-charsets=gbk,gb2312,utf8--with-pthread
Make
Make Install//NOTE: Here is the reference to others, personal installation time because the MySQL version is too high, do not support made compile, must use the CMake, you can direct yum install CMake installation
Explanation of compilation parameters:
--prefix=/usr/local/mysql/: Specify the installation location
--localstatedir=/usr/local/mysql/data: Specifying the database file location
--without-debug: Disabling call mode
--with-unix-socket-path=/tmp/mysql.sock: Specify sock file location
--with-client-ldflags=-all-static:
--with-mysqld-ldflags=-all-static: Compiling the server and client in a purely static manner
--enable-assembler: Using assembly versions of some character functions
--with-extra-charsets=gbk,gb2312,utf8:gbk,gb2312,utf8 character support
--with-pthread: Forcing the use of the Pthread library (POSIX line libraries)
For more compilation parameters, execute the./configure--help command to view.
CP support-files/my-medium.cnf/etc/my.cnf//Copy Configuration folder my.cnf
/usr/local/mysql/bin/mysql_install_db--user=mysql//Initialize Database
Chown-r Root.mysql/usr/local/mysql
Chown-r Mysql/usr/local/mysql/data
Cp/tmp/mysql-5.1.62/support-files/mysql.server/etc/rc.d/init.d/mysqld//init Startup script
Chown Root.root/etc/rc.d/init.d/mysqld
chmod 755/etc/rc.d/init.d/mysqld
Chkconfig--add mysqld
Chkconfig mysqld on
Ln-s/usr/local/mysql/bin/mysql/usr/bin
Ln-s/usr/local/mysql/bin/mysqladmin/usr/bin
Service mysqld Start
/usr/local/mysql/bin/mysqladmin-u root password ' new password '//set root password
Installing PHP5.2.17
Before compiling PHP, there are two problems to solve: the installation of Libmcrypt on CentOS 6 and some systems may not be able to find libiconv caused by errors.
1, CentOS 6 official source has no libmcrypt RPM package, we choose to compile the installation here, of course you can also import third-party source installation (CentOS 5 skip this step).
Download Source:
Cd/tmp
wget http://superb-dca2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://superb-dca2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://superb-sea2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
Tar xzf libmcrypt-2.5.8.tar.gz
Tar xzf mhash-0.9.9.9.tar.gz
Tar xzf mcrypt-2.6.8.tar.gz
Installing Libmcrypt
cd/tmp/libmcrypt-2.5.8
./configure--PREFIX=/USR
Make && make install
Installing Libmcrypt
cd/tmp/mhash-0.9.9.9
./configure--PREFIX=/USR
Make && make install
Installing MCrypt
/sbin/ldconfig//Search for shareable dynamic link libraries
cd/tmp/mcrypt-2.6.8
./configure
Make && make install
2. Resolve Libiconv errors that may occur.
Cd/tmp
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
Tar xzf libiconv-1.14.tar.gz
CD libiconv-1.14
./configure--prefix=/usr/local/libiconv
Make && make install
To start installing php-5.2.17:
cd/tmp/php-5.2.17
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/etc-- WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl--enable-ftp- -WITH-GD--enable-gd-native-ttf--with-gettext--with-mhash--enable-mbstring--with-mcrypt--enable-soap-- Enable-zip--with-iconv=/usr/local/libiconv--with-mysql=/usr/local/mysql--without-pear
Make
Make install
Explanation of compilation parameters:
--prefix=/usr/local/php: Setting the installation path
--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS: Compiling the shared Apache 2.0 module
--WITH-CONFIG-FILE-PATH=/ETC: Specify profile php.ini Address
--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D: Specify additional INI file directories
--WITH-OPENSSL: Compiling OpenSSL support
--with-zlib: Compiling zlib support
--enable-bcmath: Enable BC style precision math functions
--WITH-BZ2:BZIP2 Support
--with-curl:crul Support
--ENABLE-FTP:FTP Support
--WITH-GD:GD Support
--enable-gd-native-ttf: Enable TrueType String functions
--with-gettext: Enable GNU GetText support
--with-mhash:mhash Support
--enable-mbstring: Enable multi-byte string support
--with-mcrypt: Compiling MCrypt encryption support
--ENABLE-SOAP:SOAP Support
--enable-zip: Enable zip read/write support
--with-iconv=/usr/local/libiconv:iconv Support
--with-mysql=/usr/local/mysql: Enable MySQL support
--without-pear: Do not install pear
Additional compilation parameters are explained in the reference http://www.php.net/manual/zh/configure.about.php or./configure--help view.
CP Php.ini-dist/usr/local/php/etc/php.ini//Copy configuration file php.ini
To include PHP file type resolution in the/etc/httpd/conf/httpd.conf file:
AddType application/x-httpd-php. php
Restart httpd:
Service httpd Restart
Later discovered or not, prompted the system does not support PDO, there are various problems, and finally found on the Internet Yum installed php5.4 method, and decided to reinstall the system Yum installation, good, reinstall System!!!!
The half-day is omitted here ..... ... ..... ... .... ..... ..... ..... ..................... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ...... ..... ................................................................
After installation, yum install Apache MySQL mysql-server mysql-devel
The point is coming!!!
Use webtatic EL6 's yum source to install php5.4,
RPM-UVH http://repo.webtatic.com/yum/el6/latest.rpm
Yum Install php54w
If the installation fails, first uninstall the previous PHP
This certainly does not, it will prompt could not find driver
Because the thinkphp is useful to the PDO connection database, the PDO module must be installed!
I installed my own php54w-mysql php54w-odbc php54w-pdo.
Everyone is not the same, you install as appropriate!
List of included PHP extensions:
Package provides
php54w |
mod_php |
Php54w-bcmath |
|
Php54w-cli |
php-cgi, Php-pcntl, Php-readline |
Php54w-common |
Php-api, php-bz2, Php-calendar, Php-ctype, Php-curl, Php-date, Php-exif, Php-fileinfo, Php-ftp, Php-gettext, Php-gmp, PHP -hash, Php-iconv, Php-json, Php-libxml, Php-openssl, Php-pcre, Php-pecl-fileinfo, Php-pecl-phar, Php-pecl-zip, Php-reflection, Php-session, Php-shmop, Php-simplexml, Php-sockets, PHP-SPL, Php-tokenizer, Php-zend-abi, Php-zip, Php-zlib |
Php54w-dba |
|
Php54w-devel |
|
php54w-embedded |
Php-embedded-devel |
Php54w-enchant |
|
php54w-fpm |
|
Php54w-gd |
|
Php54w-imap |
|
Php54w-interbase |
Php_database, Php-firebird |
Php54w-intl |
|
Php54w-ldap |
|
Php54w-mbstring |
|
Php54w-mcrypt |
|
Php54w-mssql |
|
Php54w-mysql |
Php-mysqli, Php_database |
Php54w-odbc |
PHP-PDO_ODBC, Php_database |
Php54w-pdo |
|
Php54w-pgsql |
Php-pdo_pgsql, Php_database |
Php54w-process |
Php-posix, Php-sysvmsg, Php-sysvsem, PHP-SYSVSHM |
Php54w-pspell |
|
Php54w-recode |
|
Php54w-snmp |
|
Php54w-soap |
|
Php54w-tidy |
|
Php54w-xml |
Php-dom, Php-domxml, PHP-WDDX, php-xsl |
Php54w-xmlrpc |
|
Php54w-zts |
|
Finally, there is a problem!!! Tips
SQLSTATE[HY000] [2019] Can ' t initialize character set UTF-8
Here card for a long time, check a lot of, the last Daniel come over, less than two minutes to solve the problem, the reason is in the thinkphp configuration file, connect the database when the character set to UTF-8, in this UTF-8 changed to UTF8 OK!!!! This bothered me for a week of problems to be Daniel seconds!!! Daniel I worship you!!! By the way, this configuration file is in the index/conf/config.php, originally because of the thinkphp framework is not familiar, led to find this file for a long time!!! Now write my painful experience so that everyone can not take a detour!!