PHP5.5.0 is compiled and installed in source code to solve the problem of 502 error returned when curl_exec accesses HTTPS. php5.5.0curl _ exec

Source: Internet
Author: User
Tags gmp openssl library recode zts nginx server

PHP5.5.0 is compiled and installed in source code to solve the problem of 502 error returned when curl_exec accesses HTTPS. php5.5.0curl _ exec

Recently, I encountered a strange problem. When PHP uses curl_exec to access the HTTPS webpage, the error 502 is returned. If there is no problem accessing the HTTP webpage, echo phpinfo () is used. Check that openssl and curl are supported, I found a lot of information on the Internet and did not solve it.


[root@www ~]# php -VFailed loading /usr/local/zend/ZendOptimizer.so:  /usr/local/zend/ZendOptimizer.so: undefined symbol: zend_throw_exception_internalPHP Warning:  PHP Startup: memcache: Unable to initialize moduleModule compiled with module API=20060613PHP    compiled with module API=20090626These options need to match in Unknown on line 0PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/openssl.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/openssl.so: undefined symbol: zend_parse_parameters_none in Unknown on line 0

Run # php-V to check whether openssl. so fails to be loaded. It seems that it must be related to the openssl library. The openssl library is re-installed, and the problem persists. The reason is that zend is used in the openssl library. The above prompt shows that zend Library also reports an error. It is estimated that the zend library has to be re-installed for processing. This is troublesome. If you don't want to use the source code to compile php, just do it.


Download PHP 5.5.0.tar.gz

#. /Configure -- prefix =/usr -- with-config-file-path =/etc -- with-mysql =/usr/local/mysql/-- with-mysqli =/usr/local/ mysql/bin/mysql_config \ -- with-iconv-dir -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath \ -- enable-discard-path -- enable-magic-quotes -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable -sysvsem -- enable-inline-opti Mization \ -- with-curl -- with-curlwrappers -- enable-mbregex -- enable-fastcgi -- enable-fpm -- enable-force-cgi-redirect -- enable-mbstring -- with-mcrypt \-- enable-ftp -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip \ -- enable-soap -- without-pear -- with-gettext -- with-mime-magic # make ZEND_EXTRA_LIBS = '-liconv' # make test # make inst The directory to be specified for all is the installation directory of mysql, And the directory where mysql_config is located.


Some errors may occur during the installation process. The following is what I encountered during installation. The environment is different and the problems encountered by each machine are also different.


1. An error occurs. xpm. h not found.

# Yum install libXpm-devel // note that x is in uppercase
# Yum install libXext-devel // note that x is in uppercase

2. gmp. h not found

# Yum install gmp

# Yum install gmp-devel

3. error: utf8_mime2text () has new signature, but U8T_CANONICAL is missing. This shocould not happen

# Yum install libc-client-devel

4. error: Unable to detect ICU prefix or/usr/bin/icu-config failed

# Yum install libicu *

# Yum install icu *

5. error: ODBC header file '/usr/include/sqlext. H' not found

#yum install unixODBC-devel

6. error: Cannot find pspell

#yum install aspell-devel

7. error: Can not find recode. h anywhere under/usr/local/usr/opt.

# Yum install recode

# Yum install recode-devel

8. error: cocould not find net-snmp-config binary

#yum install net-snmp-devel

9. error: Cannot find libtidy

# Yum install libtidy-devel

Php installation is complete. After testing the php page, the problem persists. Finally, I checked it carefully. The phpinfo () function shows the version 5.2.17, And I installed 5.5.0, apparently, the nginx server is still using

The old php did not enable the latest php compiled and installed. I looked for it. The old php Directory is/usr/local/bin/php, the newly installed php Directory is/usr/bin/php.


Why not use the latest php? It is obviously related to the Environment Variable PATH. Run the env command to see

PATH =/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/root/bin

We can modify the/etc/profile file and put the last line of the file:


Export PATH =/usr/local/mysql/bin: $ PATH

Change

Export PATH =/usr/local/mysql/bin:/usr/bin: $ PATH


Then

# Cd/etc

# Source profile reload the profile file

Finally, test the php file. curl_exec can access the https file and obtain the data.





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.