Upgrade php under Ubuntu

Source: Internet
Author: User
Tags geoip php development environment

Upgrade php under Ubuntu

Cause:

In the current Apache + PHP environment, an error occurs when a PHP Extension is added:

Unable to initialize module
Module compiled with module API = 20090626
PHP compiled with module API = 20100525
These options need to match

This is because the compiling environment of the PHP Runtime Library is inconsistent with that of the extension package.

The solution is simple, so that the two are the same. There are two solutions: 1. Change the PHP Runtime Library version; 2. Change the extension package compiling environment version.

On my server, Apache loads a new version than the version of Ubuntu apt-get, so I chose to update the Extension compilation version of the system.

1. Clear old versions

# Remove Ubuntu PHP Packages

Sudo apt-get remove php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-geoip php5-imagick php5-intl php5-mcrypt php5-mysql php5-xdebug

# Remove PECL Packages

Sudo pecl uninstall apc

Sudo pecl uninstall geoip

Sudo pecl uninstall xdebug

2. Get the PHP specified version, which can be found on this page: http://cn2.php.net/releases/

# Get PHP 5.4.17 Source

Wget http://museum.php.net/php5/php-5.4.17.tar.bz2

Tar jxf php-5.4.17.tar.bz2

Cd php-5.4.17/

3. Compile

# Configure PHP Source

# Note: Use 'php-config' utility to determine your existing php configure options.

./Configure


# Install PHP

Make

Make test

Sudo make install

4. Use peci

Sudo pecl install ssh2 channel: // pecl.php.net/ssh2-0.12

5. Add in php. ini

Add the "extension = ssh2.so" to the extension part of php. ini

6. Restart apache

Note 1: It is possible that php. ini does not exist on the server. If so, you need to create one in the relevant directory.

For example, use <? Phpinfo ();?> Output:

Configuration File (php. ini) Path/bitnami/megastack-linux-x64/output/php/lib
Loaded Configuration File (none)
This is the output on my server. What is depressing is that this directory still does not exist. I didn't realize that php. ini didn't exist at the beginning. It took a lot of time to find it. Finally, directly create this directory and then
Sudo echo "extension = ssh2.so"> php. ini

All other configurations use the default values.

NOTE 2: the Apache server and the PHP module are not installed using apt-get of ubuntu, And they exist independently. Therefore, the latest PHP source code downloaded above is not added to this Apache server. It is only used as the environment for compiling ssh2 php extension.

Therefore, the default settings are used when no parameters are specified during configure compilation.

Deep understanding of ini configuration in PHP

Analyze the timeout mechanism of PHP scripts

Build a PHP development environment under Ubuntu 14.04 PDF

PHP 7 innovation and Performance Optimization

PHP 7, you deserve it

Experience PHP 7.0 on CentOS 7.x/Fedora 21

Install LNMP in CentOS 6.3 (PHP 5.4, MyySQL5.6)

Nginx startup failure occurs during LNMP deployment.

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

Detailed php hd scanning PDF + CD source code + full set of teaching videos

Configure the php lnmp development environment in CentOS 6

PHP details: click here
PHP: click here

This article permanently updates the link address:

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.