Php in linux

Source: Internet
Author: User
Tags openldap
First install the basic dependency formation, Note: These dependency formation is also the LINUXPHPMYSQLAPACHENGINXMEMCACHED system components necessary LANGCyum-yinstallgccgcc-cautoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develgl

First install basic dependency setup. Note: these dependency libraries are also required when LINUXPHPMYSQLAPACHENGINXMEMCACHED is required. LANG = C yum-y install gcc-c autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel gl

First, install basic dependencies. Note: These dependency components are also required for LINUX + PHP + MYSQL + APACHE + NGINX + MEMCACHED.
LANG = C

Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel gd * bzip2 bzip2-devel ncurses ncurses-devel net-snmp-devel curl-devel kernel e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel kernel openldap-clients openldap-servers libmcrypt-devel

Download php-5.4.8.tar.gz (coming soon)

# Wget http://cn2.php.net/get/php-5.4.8.tar.gz/from/this/mirror

# Tar zxvf php-5.4.8.tar.gz

# Cd php-5.4.8

. /Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-config-file-path =/usr/local/php/ etc -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-iconv-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline- optimization -- with-curl -- with-curlwrappers -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- with-freetype-dir -- enable-gd- native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-ldap-sasl -- with-xmlrpc -- enable-zip -- enable- soap -- enable-session -- with-gettext

(./Configure prompts the lack of dependency components, yum install corresponding components)

Warning information similar to this may exist during compilation:

Bytes ---------------------------------------------------------------------------------------------------------
# Configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
The solution is as follows: (or ignore it directly, which does not affect the normal installation and running of php)

Wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
Tar-zxvf re2c-0.13.5.tar.gz
Cd re2c-0.13.5
./Configure & make install

Service apache restart: the following error occurs when you restart APACHE.
Httpd: Syntax error on line 53 of/usr/local/apache2/conf/httpd. conf: Cannot load
/Usr/local/apache2/modules/libphp5.so into server:/usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

Solution: execute the following statement.

[Root @ server2 ~] # Chcon-t textrel_shlib_t '/usr/local/apache2/modules/libphp5.so'

[Root @ server2 ~] # Service apache restart
[Root @ server2 ~] # Echo $?
0


Make (this may be due to mysqlLibmysqlclient. so.18 loading failedSecond, a small error occurs. Note that this is only possible. The solution is as follows)

Make install (if the following message is displayed, it indicates that everything is successful and the installation is successful !)

Wrote PEAR system config file at:/usr/local/php/etc/pear. conf
You may want to add:/usr/local/php/lib/php to your php. ini include_path
/Var/ftp808/php-5.4.8/build/shtool install-c ext/phar. phar/usr/local/php/bin
Ln-s-f/usr/local/php/bin/phar. phar/usr/local/php/bin/phar
Installing PDO headers:/usr/local/php/include/php/ext/pdo/


Copy the php in the source code package. ini-production configuration file to the PHP installation directory (cp/var/ftp808/php-5.4.8/php. ini-production/usr/local/php/lib/php. ini)

Note: php New Version: the file name has been changed. The actual file name path varies depending on the version.

# Cp php. ini-production/usr/local/php/lib/php. ini

------------------------------

Modify the configuration file httpd. conf of apache

Add

AddType application/x-httpd-php. php

Modify the default file address DocumentRoot of www

Note that the Directoty path must be modified in the same way as the preceding one.

Restart httpd

Test the PHP File

Phpinfo ()

---------------------------------

Execute the PHP File

#/Usr/local/php/bin/php xx. php


A prompt is displayed when you execute make.:

Similar to error while loading shared libraries: libmysqlclient. so.18: cannot openError,

This indicates that libmysqlclient. so.18 is not loaded successfully. Execute the following statement to manually register and re-compile it.

Method 1:
Modify the path according to the actual installation directory of MYSQL
If mysql is installed in/usr/local/mysql, the result is
Ldconfig/usr/local/mysql/lib/libmysqlclient. so.18 (mysql5.6.12 path format)
Ldconfig/usr/local/mysql/lib/mysql/libmysqlclient. so.18 (earlier version path format)

Method 2:
Locate libmysqlclient. so.16
If mysql is installed in/usr/local/mysql, the result is
/Usr/local/mysql/lib/libmysqlclient. so.18 (mysql5.6.12 path)
/Usr/local/mysql/lib/mysql/libmysqlclient. so.18 (path of earlier mysql versions)
Vi/etc/ld. so. conf
Add/usr/local/mysql/lib
Then execute ldconfig to take effect.
If none of the above methods take effect, you may need method 3:

Method 3:
Open/etc/ld. so. conf
Include ld. so. conf. d/*. conf
Add
/Usr/local/mysql (based on the actual installation path)
/Usr/local/mysql/lib (based on the actual installation path, here is the path format of the new version compiled by cmake, 5. the old version above X is generally/usr/local/mysql/lib/mysql /)

Run ldconfig.

Method 1 adopted by my home computer, method 3 adopted by the server, and method 2 used by VPS

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.