Remember a painful process ------- source code compilation and installation of apache + php5 + mysql

Source: Internet
Author: User
Tags mcrypt automake

At that time, we were preparing to build a project, so I built the lamp server and directly installed all the files in yum, because centos is a relatively stable system, therefore, none of the above software is up-to-date. apache is 2.2.15, php is 5.3.3, and mysql is 5.1.69. the error message is displayed on the page. I forgot what I was prompted. There was no problem when I put it locally. Later I found that the thinkphp framework was the cause, and some syntaxes do not support php5.4 or lower, so I decided to Upgrade php, so the painful process began !!!!

The first thought was to change the source to centos and the server to version 6.3. The server first changed the source to version 163 and later to the source of HKUST, yum info php is 5.3.3, and later decided to install php in the source code, but later found that the installation directory of apache and mysql must be added during compilation. Because it is apache and mysql installed in yum, there is no way to add directories, so I decided to re-compile all of them !!! Good. Go to the source code first!

Uninstall the amp software installed by yum or rpm
Before compiling and installing lamp, 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 compilation and installation to fail. Disable it first.
Sed-I's/SELINUX = enforcing/SELINUX = disabled/G'/etc/selinux/config // permanently disabled and must be restarted to take effect
Setenforce 0 // temporarily disabled, no need to restart
Install necessary tools in yum
1. Install the compilation tool gcc-c ++ make automake autoconf kernel-devel
2, install PHP required dependencies, such as libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel etc.
Yum-y install gcc-c ++ make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-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 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 selected here is: apache-2.2.22, mysql-5.1.62, php-5.2.17, phpmyadmin-3.4.10.2
Cd/tmp
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 wget-c
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
Install apache2.2.22
D/tmp/httpd-2.2.22
. /Configure -- prefix =/usr/local/apache -- with-stored ded-apr -- enable-so -- enable-deflate = shared -- enable-expires = shared -- enable-headers = shared -- enable-rewrite = shared -- enable-static-support
Make
Make install
Compilation parameter explanation:
-- Prefix =/usr/local/apache: Specifies the installation directory.
-- With-embedded ded-apr: the version of the APR bound to the current source code is forcibly used during compilation.
-- Enable-so: allows the DSO module to be loaded at runtime.
-- Enable-deflate = shared: Compile the deflate module into DSO
-- Enable-expires = shared: Compile the expires module into DSO
-- Enable-headers = shared: Compile the headers module as DSO
-- Enable-rewrite = shared: Compile the rewrite module into DSO
-- Enable-static-support: use static connections (Dynamic connections by default) to compile all binary support Programs
More detailed compilation parameter explanation: http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html
Cp build/rpm/httpd. init/etc/init. d/httpd // use the init script to manage httpd
Chmod 755/etc/init. d/httpd // Add execution permission
Chkconfig -- add httpd // add httpd to service item
Chkconfig httpd on // set startup
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 adapt to the init script
Install mysql5.1.62
Groupadd mysql
Useradd-g mysql
D/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-validator -- with-extra-charsets = gbk, gb2312, utf8 -- with-pthread
Make
Make install // Note: Here is the reference of others. During personal installation, because the mysql version is too high, make compilation is not supported and cmake must be used. You can directly install yum install cmake
Compilation parameter explanation:
-- Prefix =/usr/local/mysql/: Specifies the installation location
-- Localstatedir =/usr/local/mysql/data: Specifies the location of the database file.
-- Without-debug: Disable the call mode.
-- With-unix-socket-path =/tmp/mysql. sock: Specifies the location of the sock file.
-- With-client-ldflags =-all-static:
-- With-mysqld-ldflags =-all-static: Compile the server and client in pure static mode
-- Enable-aggreger: The Assembly version of some character functions.
-- With-extra-charsets = gbk, gb2312, utf8: gbk, gb2312, and utf8 characters are supported.
-- With-pthread: enforces the use of the pthread Library (posix thread Library)
For more compilation parameters, run the./configure -- help Command.
Cp support-files/my-medium.cnf/etc/my. cnf // copy the configuration folder my. cnf
/Usr/local/mysql/bin/mysql_install_db -- user = mysql // initialize the 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 start 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 the root password
Install PHP5.2.17
Before compiling php, you must solve two problems: the installation of libmcrypt on centos 6 and the errors caused by libiconv failure in some systems.
1. centos 6 official sources do not have the libmcrypt rpm package. Here we choose to compile and install it. Of course, you can also import the third source for installation (centos 5 skipped this step ).
Download source code:
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
// Install libmcrypt
D/tmp/libmcrypt-2.5.8
./Configure -- prefix =/usr
Make & make install
// Install libmcrypt
D/tmp/mhash-0.9.9.9
./Configure -- prefix =/usr
Make & make install
// Install mcrypt
/Sbin/ldconfig // search for a shared Dynamic Link Library
D/tmp/mcrypt-2.6.8
./Configure
Make & make install
2. Solve possible libiconv errors.
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
Start php-5.2.17 installation:
D/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
Compilation parameter explanation:
-- Prefix =/usr/local/php: Set the installation path.
-- With-apxs2 =/usr/local/apache/bin/apxs: Compile the shared Apache 2.0 Module
-- With-config-file-path =/etc: Specifies the php. ini address of the configuration file.
-- With-config-file-scan-dir =/etc/php. d: specify an additional INI file directory.
-- With-openssl: OpenSSL compilation support
-- With-zlib: zlib compilation support
-- Enable-bcmath: enables the BC style precision mathematical function.
-- With-bz2: BZip2 support
-- With-curl: supported by CRUL
-- Enable-ftp: FTP support
-- With-gd: GD supported
-- Enable-gd-native-ttf: enable the TrueType string function.
-- With-gettext: supports GNU gettext.
-- With-mhash: mhash supported
-- Enable-mbstring: enable multi-byte string
-- With-mcrypt: supports compiling mcrypt Encryption
-- Enable-soap: SOAP support
-- Enable-zip: enable zip read/write support
-- With-iconv =/usr/local/libiconv: iconv supported
-- With-mysql =/usr/local/mysql: mysql support enabled
-- Without-pear: do not install PEAR
For more compilation parameters, see http://www.php.net/manual/zh/configure.about.php#./configure -- help.
Cp php. ini-dist/usr/local/php/etc/php. ini // copy the configuration file php. ini
Add the PHP file type resolution to the/etc/httpd/conf/httpd. conf file:
Addtype application/x-httpd-php. php
Restart httpd:
Service httpd restart

Later, I found that the system still does not support pdo, and there are various problems. Finally, I found the yum Installation Method for php5.4 on the Internet, and decided to reinstall the yum installation, reinstall the system !!!!

Here, half a day is omitted ..................................... ........................................ ........................................ ........................................ ......................

After installation, yum install apache mysql-server mysql-devel

The point is coming !!!!

Use the YUM source of Webtatic EL6 to install php5.4,

Rpm-Uvh http://repo.webtatic.com/yum/el6/latest.rpm

Yum install php54w

If the installation fails, uninstall the previous php

This will definitely not work. It will promptCocould not find driver

The pdo module must be installed because pdo is used in thinkphp to connect to the database!

I installed a php54w-mysql php54w-odbc php54w-pdo myself.

The situation varies with everyone. You can install it as appropriate!

 

Included php extension list:
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 and 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, a problem occurred !!! Prompt

SQLSTATE [HY000] [2019] Can't initialize character set UTF-8

The problem was solved in less than two minutes after I checked it for a long time. The reason was that it was in the Thinkphp configuration file, when the database is connected to the character set to UTF-8, In this UTF-8 to UTF8 is OK !!!! The problem that plagued me for a week has become quite cool !!! I worship you !!! By the way, this configuration file is in Index/conf/config. php. It was a long time to find this file because it was not familiar with the thinkphp framework !!! Now I want to write down my painful experience to avoid detours !!

Related Article

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.