Linux Build Php+mysql+apache Environment

Source: Internet
Author: User
Tags configuration php gz file mcrypt mysql client phpinfo sapi

Environment:

CentOS 6.4

MySQL detailed installation can refer to: http://www.cnblogs.com/yangxia-test/archive/2012/11/12/2766237.html

Apache detailed installation can be consulted: http://www.cnblogs.com/yangxia-test/archive/2012/11/09/2762486.html

First, download the file

1, php:http://php.net/downloads.php version: php-5.6.3.tar.gz

2, libxml2:http://download.chinaunix.net/download/0007000/6095.shtml version: libxml2-2.7.4.tar.gz

3, apache2:http://httpd.apache.org/version: httpd-2.4.10.tar.gz

4. Apr and apr-util:http://apr.apache.org version: apr-1.5.1.tar.gz/apr-util-1.5.4.tar.gz

5, pcre:http://sourceforge.net/projects/pcre/files/pcre/version: pcre-8.36.tar.gz

6, mysql:http://dev.mysql.com/downloads/mysql/5.1.73.html

mysql-devel-community-5.1.73-1.rhel5.x86_64.rpm

mysql-client-community-5.1.73-1.rhel5.x86_64.rpm

mysql-server-community-5.1.73-1.rhel5.x86_64.rpm

Download

Second, install MySQL

1, the binary installation of MySQL, the steps are as follows:

[Email protected] mysql]# RPM-IVH mysql-server-community-5.1.73-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-server-community ########################################### [100%]

REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:

/usr/bin/mysqladmin-u root password ' new-password '
/usr/bin/mysqladmin-u root-h vm15.example.com password ' new-password '

Alternatively you can run:
/usr/bin/mysql_secure_installation

Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.

See the Manual for more instructions.

Problems with The/usr/bin/mysqlbug script!

Starting MySQL. success!
Giving mysqld 2 seconds to start

[Email protected] mysql]# RPM-IVH mysql-client-community-5.1.73-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-client-community ########################################### [100%]

[Email protected] mysql]# RPM-IVH mysql-devel-community-5.1.73-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-devel-community ########################################### [100%]

2. Verify the installation is successful

[[email protected] mysql]# rpm-qa |grep MySQL
Mysql-client-community-5.1.73-1.rhel5.x86_64
Mysql-devel-community-5.1.73-1.rhel5.x86_64
Mysql-server-community-5.1.73-1.rhel5.x86_64

[[email protected] mysql]# MySQL

There is a "mysql>" prompt, congratulations, installation success!

Third, install Apache

Reference: http://www.cnblogs.com/yangxia-test/archive/2012/11/09/2762486.html

Iv. installation of LIBXML2

Upload the downloaded libxml2-2.7.4.tar.gz file to/usr/local

[Email protected] local]# mkdir-p LIBXML2
[Email protected] local]# TAR-ZXVF libxml2-2.7.4.tar.gz
[Email protected] local]# CD libxml2-2.7.4
[Email protected] libxml2-2.7.4]#/configure--PREFIX=/USR/LOCAL/LIBXML2
[[email protected] libxml2-2.7.4]# make
[[email protected] libxml2-2.7.4]# make install

If the installation succeeds, the bin, include, Lib, and share four directories will be generated under the/usr/local/libxml2/directory. When you install the configuration of the PHP5 source package later, you specify the location where the LIBXML2 library files are installed by adding the "--with-libxml-dir=/usr/local/libxml2" option in the options for the Configure command.

V. Installation of PHP

Upload the downloaded php-5.6.3.tar.gz file to/usr/local

[[email protected] local]# mkdir-p PHP
[Email protected] local]# TAR-ZXVF php-5.6.3.tar.gz
[Email protected] local]# CD php-5.6.3
[Email protected] php-5.6.3]#./configure--prefix=/usr/local/php--with-mysql--with-apxs2=/usr/local/apache2/bin/ APXS--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2

The following message appears indicating successful compilation

..
Checking for external Oniguruma ... no
Checking for MCrypt support ... no
Checking for MSSQL support via FreeTDS ... no
Checking for MySQL support ... yes
Checking for specified location of the MySQL UNIX socket ... no
Configure:error:Cannot find MySQL header files Under/usr/local/mysql.
Note that the MySQL client library isn't bundled anymore!

Creating Libtool
Appending configuration Tag "CXX" to Libtool

Generating files
Configure:creating./config.status
Creating MAIN/INTERNAL_FUNCTIONS.C
Creating MAIN/INTERNAL_FUNCTIONS_CLI.C
+--------------------------------------------------------------------+
| License: |
| This software was subject to the PHP License, available in this |
| Distribution in the file LICENSE. By continuing this installation |
| Process, you is bound by the terms of this License agreement. |
| If you don't agree with the terms of this license, you must abort |
| The installation process at this point. |
+--------------------------------------------------------------------+

Thank for using PHP.

Config.status:creating Php5.spec
Config.status:creating Main/build-defs.h
Config.status:creating scripts/phpize
Config.status:creating scripts/man1/phpize.1
Config.status:creating Scripts/php-config
Config.status:creating Scripts/man1/php-config.1
Config.status:creating SAPI/CLI/PHP.1
Config.status:creating SAPI/CGI/PHP-CGI.1
Config.status:creating Ext/phar/phar.1
Config.status:creating Ext/phar/phar.phar.1
Config.status:creating main/php_config.h
config.status:executing default Commands

[[email protected] php-5.6.3] #make

[[email protected] php-5.6.3] #make Install

The installation was successful.

Vi. Configuration of PHP

1, configuration php.ini, only need to copy the php.ini-production in the php-5.6.3 installation package to/usr/local/php/lib/

[email protected] php-5.6.3]# CP Php.ini-production/usr/local/php/lib/php.ini

2. Configure HTTPD.CONF to allow Apache to support PHP:

# vi/usr/local/apache/conf/httpd.conf

Locate AddType application/x-gzip. gz. tgz below to add the following

AddType application/x-httpd-php. PHP (with spaces in front)

AddType Application/x-httpd-php-source. PHPS (front with spaces)

3. Increase index.php in directoryindex so that Apache can identify the index in PHP format

# vi/usr/local/apache/conf/httpd.conf

<ifmodule dir_module>      directoryindex index.html index.php  

Seven, restart Apache

[[email protected] mysql]# /usr/local/apache2/bin/apachectl start

( Be sure to restart)

Viii. Test if PHP is installed successfully

Write a PHP test page info.php, and put it in/usr/local/apache2/htdocs.

<?php

Phpinfo ();

?>;

Enter in the browser: server address/info.php. With Phpinfo (), you can see a lot of information, such as PHP.ini's storage path, and all of the extension components, are very powerful.

If the PHP information can be displayed correctly, the apche+mysql+php installation is successful!

Nine, the installation encountered problems

1, when installing MySQL, reported the following error:

[Email protected] mysql]# RPM-IVH mysql-server-community-5.1.73-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
File/usr/share/mysql/charsets/readme from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with file From Package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/index.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with File from Package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/armscii8.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts With file from the package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/ascii.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with File from Package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/cp1250.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with File from Package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/cp1251.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with File from Package mysql-libs-5.1.73-3.el6_5.x86_64
File/usr/share/mysql/charsets/cp1256.xml from install of mysql-server-community-5.1.73-1.rhel5.x86_64 conflicts with File from Package mysql-libs-5.1.73-3.el6_5.x86_64

workaround : Yum Remove mysql-libs-5*

2, configure PHP, error:

Configuring SAPI Modules
Checking for aolserver support ... no
Checking for Apache 1.x module support via DSO through APXS ... configure:error:You with enabled Apache 1.3 support while Your server is Apache 2. Use the appropriate switch--WITH-APXS2

workaround :./configure--prefix=/usr/local/php--with-mysql --with-apxs2=/usr/local/apache2/bin/apxs- -with-libxml-dir=/usr/local/libxml2

3, install APR, error rm:cannot remove ' Libtoolt ': No such file or directory

Workaround :

Just open the/usr/local/apr-1.5.1/configure and remove the $RM $cfgfile.
$RM "$cfgfile" is about 42302 lines

[Email protected] apr-1.5.1]#grep-n RM Configure

[[email protected] apr-1.5.1]#sed-i '/$RM "$cfgfile"/d ' Configure

and then rerun it./configure--PREFIX=/USR/LOCAL/APR.

4, [[email protected] php-5.6.3]#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-apxs2=/usr /local/apache2/bin/apxs--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2

..
Checking for external Oniguruma ... no
Checking for MCrypt support ... no
Checking for MSSQL support via FreeTDS ... no
Checking for MySQL support ... yes
Checking for specified location of the MySQL UNIX socket ... no
Configure:error:Cannot find MySQL header files Under/usr/local/mysql.
Note that the MySQL client library isn't bundled anymore!

Workaround :

[Email protected] php-5.5.6]# Find/-name mysql.h
/usr/include/mysql/mysql.h

To find the Mysql.h file, we change the parameter to --with-mysql, if not, install the mysql-devel package,

Linux Build Php+mysql+apache Environment

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.