PHP installation and configuration in Linux (CentOS-6.5: php-5.2.13 ),

Source: Internet
Author: User
Tags mcrypt php introduction upload php

PHP installation and configuration in Linux (CentOS-6.5: php-5.2.13 ),


1 PHP introduction PHP (abbreviation of PHP: Hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a common open source scripting language. The syntax absorbs the features of C language, Java, and Perl. It has a low entry threshold, is easy to learn, and is widely used. It is mainly applicable to the Web development field. PHP file Suffix: php.


2) libmcrpyt
Ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

2) php
Http://www.php.net/

3) This installation of all the software package (installation environment: CentOS-6.5)
Http://download.csdn.net/detail/clevercode/8676163

3 installation instructions 1) PHP installation is relatively complicated. Refer to the lnmp installation method from Baidu experience.
Web: http://jingyan.baidu.com/article/915fc414cc28ec51394b2032.html

2) install lnmp. System conventions:
Software source code package storage location:/usr/local/src/software name
Source code package compilation and installation location:/usr/local/software name


4 installation Step 4.1 install libiconv

Before installation, make sure to install the Linux support database. Otherwise, various errors may occur! Installation of common support libraries in Linux: http://blog.csdn.net/clevercode/article/details/45438401

# Cd/usr/local/src/php

# Tar zxvf libiconv-1.13.tar.gz
# Cd libiconv-1.13
#./Configure -- prefix =/usr/local
# Make
# Make install


4.2 install libmcrypt # cd/usr/local/src/php
# Tar zxvf libmcrypt-2.5.8.tar.gz # Extract
# Cd libmcrypt-2.5.8 # enter the Directory
#./Configure # Configuration
# Make # compile
# Make install # install


4.3 install mhash # cd/usr/local/src/php
# Tar zxvf mhash-0.9.9.9.tar.gz
# Cd mhash-0.9.9.9/
#./Configure
# Make
# Make install


4.4 create a soft link ln-s/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la
Ln-s/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. so
Ln-s/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4
Ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8
Ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config


Cp-frp/usr/lib64/libjpeg. */usr/lib/
Cp-frp/usr/lib64/libpng */usr/lib/
Cp-frp/usr/lib64/libldap */usr/lib/


4.5 install PHP1) create a www user for php-fpm.
# Groupadd www # Add a www Group
# Useradd-g www-s/bin/false # create an nginx Running Account www and add it to the www group. www users are not allowed to log on to the system directly.


2) create an installation directory, cache directory, and log directory.
A) Installation Directory
# Mkdir-p/usr/local/php5
B) cache directory
# Mkdir-p/tmp/phis
# Chown www: www/tmp/phis-R
C) session Directory. If multiple Server Load balancer servers need to share the session, the session needs to be placed in memcach.
# Mkdir-p/tmp/session
# Chown www: www/tmp/session-R
D) Create a log directory.
# Mkdir-p/data0/logs/php
# Chown www: www/data0/logs/php-R


3) decompress
Make sure that mysql-devel is installed and/usr/lib64/mysql is generated
In a 64-bit system, libmysqlclient is installed in the/usr/lib64/mysql/directory by default.
When php is compiled, it is searched under the/usr/lib directory. Therefore, you need to create a soft connection.


# Ln-s/usr/lib64/mysql/libmysqlclient */usr/lib
#/Sbin/ldconfig
# Cd/usr/local/src/php
# Tar-xvpf php-5.2.13.tar.bz2


4) patch
# Gzip-cd php-5.2.13-fpm-0.5.13.diff.gz | patch-d php-5.2.13-p1


5) Configuration
# Cd php-5.2.13/
#./Configure -- prefix =/usr/local/php5 \
-- With-config-file-path =/usr/local/php5/etc \
-- With-mysql =/usr/include/mysql \
-- With-mysqli =/usr/lib64/mysql/mysql_config \
-- With-iconv-dir =/usr/local -- with-freetype-dir -- with-jpeg-dir \
-- With-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml \
-- Disable-rpath -- enable-discard-path -- enable-safe-mode \
-- Enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization \
-- With-curl -- with-curlwrappers -- enable-mbregex -- enable-fastcgi \
-- Enable-fpm \
-- Enable-force-cgi-redirect -- enable-mbstring \
-- With-mcrypt -- with-gd -- enable-gd-native-ttf \
-- With-openssl -- with-mhash -- enable-pcntl -- enable-sockets \
-- With-ldap-sasl -- with-xmlrpc -- enable-zip -- enable-soap \
-- Without-pear -- with-pdo-mysql


6) Compile
Make ZEND_EXTRA_LIBS = '-liconv'


7) Installation

Make install


4.6 install PHP extension module 1) install memcache
Cd/usr/local/src/php
Tar zxvf memcache-2.2.5.tgz
Cd memcache-2.2.5/
/Usr/local/php5/bin/phpize
./Configure -- with-php-config =/usr/local/php5/bin/php-config
Make
Make install
Cd ../


4.7 configure PHP Method 1: manual Configuration
1) copy the php configuration file to the installation directory.
# Cp/usr/local/src/php/php-5.2.13/php. ini-dist/usr/local/php5/etc/php. ini


2) Delete the built-in configuration file.
# Rm-rf/etc/php. ini


3) add soft links
# Ln-s/usr/local/php5/etc/php. ini/etc/php. ini


4) Edit
Vi/usr/local/php5/etc/php-fpm.conf
User = www # Set the php-fpm runtime account to www
Group = www # Set the php-fpm running group to www
Pid = run/php-fpm.pid # Remove the semicolon above


# Set php-fpm to start and copy php-fpm to the startup directory
# Cp/usr/local/php5/sbin/php-fpm/etc/rc. d/init. d/php-fpm
# Add execution permission
Chmod + x/etc/rc. d/init. d/php-fpm
# Set startup
Chkconfig php-fpm on


# Editing the configuration file
Vi/usr/local/php5/etc/php. ini
Find: disable_functions =
To:
Disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, disconnect, dl, openlog, syslog, readlink, symlink, release, delimiter, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_getgrnam, posix_getgroups, posix_getlogin, delimiter, delimiter, posix_getpid, delimiter, delimiter, posix_getpwuid, delimiter, posix_getsid, posix_getuid, delimiter, posix_kill, posix_mkfifo, delimiter, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname
# List functions that can be disabled by PHP. If some programs need this function, they can be deleted and disabled.
Locate:; date. timezone =
Change to: date. timezone = PRC # set the time zone
Find: expose_php = On
Change to: expose_php = OFF # disable display of php version information
PS: During the PHP compilation process, the undefined reference to 'libiconv _ OPEN error may be reported that php libiconv cannot be compiled.


# Configure php commands

Ln-s/usr/local/php5/bin/php/usr/bin/


Method 2: Upload File configuration (: http://download.csdn.net/detail/clevercode/8676163)
1) Upload php. ini
# Cd/usr/local/php5/etc/
# Rz php. ini
# Ln-s/usr/local/php5/etc/php. ini/etc/php. ini
2) Upload php-fpm.conf
# Cd/usr/local/php5/etc
# Php-fpm.conf


4.8 start stop restart php-fpm1) Start
# Cd/usr/local/php5/sbin
#./Php-fpm start


2) Stop
#./Php-fpm stop


2) Restart

#./Php-fpm restart


4.9 configure Nginx to support php

For more information, see my other blog: Nginx installation and configuration in Linux (CentOS-6.5: nginx-1.5.0)
Web: http://blog.csdn.net/clevercode/article/details/45442155


Original works, from "CleverCode blog", Please note the following original address when reprinting; otherwise, the copyright will be held legally liable.

Original address: http://blog.csdn.net/clevercode/article/details/45579837 (reprint must indicate the address ).

Blog column address (installation and configuration of common Linux software): http://blog.csdn.net/column/details/linuxsoftwareinstall.html.

Welcome to my blog for more highlights: http://blog.csdn.net/clevercode.




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.