Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 6.5 how to compile and install PHP 5.4.25

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces CentOS 6.5 how to compile and install PHP 5.4.25, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

one。 Environmental preparation

The installation path for apache is / webserver/httpd

The installation path for MySQL is / webserver/mysql

1. Installation of dependent packages

[root@WebServer ~] # yum install-y gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel

Installation of 2.PHP support libraries

The software used are

Eaccelerator-eaccelerator-42067ac.tar.gz

ImageMagick.tar.gz

Imagick-3.1.2.tgz

Libevent-2.0.21-stable.tar.gz

Libiconv-1.14.tar.gz

Libmcrypt-2.5.8.tar.gz

Mcrypt-2.6.8.tar.gz

Memcache-2.2.7.tgz

Memcached-1.4.17.tar.gz

Mhash-0.9.9.9.tar.gz

Php-5.4.25.tar.gz

[root@WebServer ~] # tar zxvf libiconv-1.14.tar.gz [root@WebServer ~] # cd libiconv-1.14 [root@WebServer libiconv-1.14] #. / configure-- prefix=/webserver/libiconv [root@WebServer libiconv-1.14] # make & & make install [root@WebServer libiconv-1.14] # cd. [root@WebServer ~] # tar zxvf libmcrypt-2.5.8.tar.gz [root@WebServer ~] # cd libmcrypt-2.5.8 [root @ WebServer libmcrypt-2.5.8] #. / configure [root@WebServer libmcrypt-2.5.8] # make & & make install [root@WebServer libmcrypt-2.5.8] # / sbin/ldconfig [root@WebServer libmcrypt-2.5.8] # cd libltdl/ [root@WebServer libltdl] #. / configure-- enable-ltdl-install [root@WebServer libltdl] # make & & make install [root@WebServer libltdl] # cd. /. [root@WebServer ~] # tar zxvf mhash -0.9.9.9.tar.gz [root@WebServer ~] # cd mhash-0.9.9.9 [root@WebServer mhash-0.9.9.9] #. / configure [root@WebServer mhash-0.9.9.9] # make & & make install [root@WebServer mhash-0.9.9.9] # cd / usr/lib64/ [root@WebServer lib64] # ln-s / usr/local/lib/*. [root@WebServer lib64] # ln-s / Usr/local/bin/libmcrypt-config / usr/bin/libmcrypt-config [root@WebServer lib64] # cd [root@WebServer ~] # tar zxvf mcrypt-2.6.8.tar.gz [root@WebServer ~] # cd mcrypt-2.6.8 [root@WebServer mcrypt-2.6.8] # / sbin/ldconfig [root@WebServer mcrypt-2.6.8] #. / configure [root@WebServer mcrypt-2.6.8] # make & & make install [root@WebServer mcrypt-2.6.8] # cd.

two。 Start compiling and installing PHP

1. Extract PHP and enter the installation directory

[root@WebServer ~] # tar zxvf php-5.4.25.tar.gz [root@WebServer ~] # cd php-5.4.25

two。 Compile PHP

[root@WebServer php-5.4.25] # / configure-- prefix=/webserver/php-- with-config-file-path=/webserver/php/etc-- with-apxs2=/webserver/httpd/bin/apxs-- with-mysql=/webserver/mysql/-- with-mysqli=/webserver/mysql/bin/mysql_config-- with-pdo-mysql=/webserver/mysql/-- with-iconv-dir=/webserver/libiconv/-- disable-phar-- with-pcre-regex-- with- Zlib--with-bz2-- enable-calendar-- with-curl-- enable-dba-- with-libxml-dir-- enable-ftp-- with-gd-- with-jpeg-dir-- with-png-dir-- with-zlib-dir-- with-freetype-dir-- enable-gd-native-ttf-- enable-gd-jis-conv-- with-mhash-- enable-mbstring-- with-mcrypt-enable-pcntl-- enable-xml-- disable-rpath-- enable-shmop -enable-sockets-enable-zip-- enable-bcmath-- with-snmp-- disable-ipv6-- with-gettext

Another version

/ configure-- prefix=/usr/local/php5.5.32-- with-config-file-path=/usr/local/php5.5.32/etc-- with-mysql=mysqlnd-- with-mysqli=mysqlnd-- with-pdo-mysql=mysqlnd-- with-iconv-dir=/usr/local/libiconv1.14-- disable-phar-- with-pcre-regex-- with-zlib-- with-bz2-- enable-calendar-- with-curl-- enable-dba-- with-libxml-dir-- enable-ftp-- With-gd-with-jpeg-dir-with-png-dir-with-zlib-dir-with-freetype-dir-enable-gd-native-ttf-enable-gd-jis-conv-with-mhash-enable-mbstring-with-mcrypt-enable-pcntl-enable-xml-disable-rpath-enable-shmop-enable-sockets-enable-zip enable-bcmath-with-snmp-disable-ipv6-with-gettext-enable-opcache- -enable-fpm-with-fpm-user=www-with-fpm-group=www

3. Installation

[root@WebServer php-5.4.25] # make [root@WebServer php-5.4.25] # make install

4. Copy the php configuration file

[root@WebServer php-5.4.25] # cp php.ini-production / webserver/php/etc/php.ini

three。 Compile and install the extension module of PHP

1. Install memcache

[root@WebServer ~] # tar zxvf memcache-2.2.7.tgz [root@WebServer ~] # cd memcache-2.2.7 [root@WebServer memcache-2.2.7] # / webserver/php/bin/phpizeConfiguring for:PHP Api Version: 20100412Zend Module Api No: 220100525 [root@WebServer memcache-2.2.7] #. / configure-- enable-memcache-- with-php-config=/webserver/php/bin/php-config [ Root@WebServer memcache-2.2.7] # make [root@WebServer memcache-2.2.7] # make installInstalling shared extensions: / webserver/php/lib/php/extensions/no-debug-zts-20100525/ [root@WebServer memcache-2.2.7] # cd..

two。 Install memcached

[root@WebServer ~] # tar zxvf libevent-2.0.21-stable.tar.gz [root@WebServer ~] # cd libevent-2.0.21-stable [root@WebServer libevent-2.0.21-stable] #. / configure-- prefix=/webserver/libevent [root@WebServer libevent-2.0.21-stable] # make & & make install [root@WebServer libevent-2.0.21-stable] # cd. [root@WebServer ~] # tar zxvf memcached-1.4.17. Tar.gz [root@WebServer ~] # cd memcached-1.4.17 [root@WebServer memcached-1.4.17] #. / configure-- prefix=/webserver/memcached-- with-libevent=/webserver/libevent [root@WebServer memcached-1.4.17] # make & & make install [root@WebServer memcached-1.4.17] # cd.. # launch memcached Use the following command: [root@WebServer ~] # / webserver/memcached/bin/memcached-d-m 512-c 2048-p 11211-P / tmp/memcached.pid-u nobody

Memcached startup parameters:

-p specifies the port number (default 11211)

-U UDP listening port (default: 11211, closed at 0)

-s UNIX socket path for listening (network support disabled)

-a UNIX socket access mask, octal digits (default: 0700)

-m specifies the maximum used memory size (default 64MB)

-t threads (default 4)

-l bind address (default: all are allowed. No matter whether the IP is changed in the internal or public network or locally, there is a security risk. If it is set to 127.0.0.1, it can only be accessed locally)

-d start starts the memcached service

-d restart restarts memcached service

-d stop | shutdown shuts down the running memcached service

The-u binding is specified to run the process (only root users can use this parameter, memcached is not allowed to run with root permissions)

-P writes PID to a file, which allows a quick process termination later, which needs to be used in conjunction with-d

-m maximum memory usage, in MB. Default 64MB

-M returns an error when memory is exhausted instead of deleting an item

-c maximum number of simultaneous connections. Default is 1024.

-f block size growth factor, default is 1.25

-n minimum allocated space. Key+value+flags defaults to 48.

-k locks all memory pages. Note the maximum amount of memory you can lock.

3. Install ImageMagick

[root@WebServer ~] # tar zxvf ImageMagick.tar.gz [root@WebServer ~] # cd ImageMagick-6.8.8-7 / [root@WebServer ImageMagick-6.8.8-7] #. / configure [root@WebServer ImageMagick-6.8.8-7] # make & & make install [root@WebServer ImageMagick-6.8.8-7] # cd.

4. Install imagick

[root@WebServer ~] # tar zxvf imagick-3.1.2.tgz [root@WebServer ~] # cd imagick-3.1.2 [root@WebServer imagick-3.1.2] # export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ [root @ WebServer imagick-3.1.2] # / webserver/php/bin/phpize [root@WebServer imagick-3.1.2] #. / configure-- with-php-config=/webserver/php/bin/php-config [root@ WebServer imagick-3.1.2] # make [root@WebServer imagick-3.1.2] # make installInstalling shared extensions: / webserver/php/lib/php/extensions/no-debug-zts-20100525/Installing header files: / webserver/php/include/php/ [root@WebServer imagick-3.1.2] # cd..

5. Install eaccelerator

[root@WebServer ~] # tar zxvf eaccelerator-eaccelerator-42067ac.tar.gz [root@WebServer ~] # cd eaccelerator-eaccelerator-42067ac [root@WebServer eaccelerator-eaccelerator-42067ac] # / webserver/php/bin/phpize Configuring for:PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525 [root@WebServer eaccelerator-eaccelerator-42067ac] #. / configure-- enable-eaccelerator=shared-- with-php-config=/webserver/php/bin/php-config [root@WebServer eaccelerator-eaccelerator-42067ac] # make & & make install

Establish an eaccelerator cache directory and change permissions

[root@WebServer eaccelerator-eaccelerator-42067ac] # mkdir-p / webserver/cache/eaccelerator [root@WebServer eaccelerator-eaccelerator-42067ac] # chmod 777 / webserver/cache/eaccelerator

6. Modify php configuration file

[root@WebServer php-5.4.25] # vim / webserver/php/etc/php.ini// press shift+g to jump to the end of the configuration file Add the following configuration information: extension_dir = "/ webserver/php/lib/php/extensions/no-debug-zts-20100525/" extension= "memcache.so" extension= "imagick.so" [eaccelerator] zend_extension= "/ webserver/php/lib/php/extensions/no-debug-zts-20100525/eaccelerator.so" eaccelerator.shm_size= "64" eaccelerator.cache_dir= "/ webserver/cache/eaccelerator" eaccelerator.enable= "1" eaccelerator.optimizer= "1" eaccelerator.check_mtime= "1" eaccelerator .debug = "0" eaccelerator.filter= "" eaccelerator.shm_max= "0" eaccelerator.shm_ttl= "3600" eaccelerator.shm_prune_period= "3600" eaccelerator.shm_only= "0" eaccelerator.compress= "1" eaccelerator.compress_level= "9"

7. Check whether the PHP module is mounted properly

[root@WebServer ~] # / webserver/php/bin/php-m [PHP Modules] bcmathbz2calendarCorectypecurldatedbadomeAcceleratoreregfileinfofilterftpgdhashiconvimagickjsonlibxmlmbstringmcryptmemcachemhashmysqlmysqlipcntlpcrePDOpdo_mysqlpdo_ sqliteposixReflectionsessionshmopSimpleXMLsnmpsocketsSPLsqlite3standardtokenizerxmlreaderxmlwriterzipzlib [Zend Modules] eAccelerator

You can see that it is mounted normally.

8.PHP security settings

a. Disable some features

[root@WebServer ~] # vim / webserver/php/etc/php.ini modify these: cgi.fix_pathinfo=0disable_functions=exec,system,eval,passthru,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,fsocket,fsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

b. Hide apache version information

[root@WebServer ~] # vim / webserver/httpd/conf/httpd.conf// add the following 2 lines of ServerTokens ProductOnlyServerSignature Off// to restart apache, and you can only see: Server: Apache in the http header

c. Hide PHP version information

[root@WebServer ~] # vim / webserver/php/etc/php.iniexpose_php = On is changed to expose_php = Off to restart apache, the php version is hidden in the http header

d. Save session to memcached, settings for php

[root@WebServer ~] # vim / webserver/php/etc/php.ini# modify the following information session.save_handler = memcachesession.save_path = "tcp://127.0.0.1:11211"

IV. Modification of Apache configuration file

[root@WebServer ~] # vim / webserver/httpd/conf/httpd.conf// find the following location to add index.php DirectoryIndex index.php index.html// add AddType application/x-httpd-php .php .phtmlAddType application/s-httpd-php-source .phps at the end of the file

Create a new index.php for the test

[root@WebServer ~] # vim / webserver/httpd/htdocs/index.php

Create a new test session and save it to memcached's test.php

Restart the apache service

[root@WebServer ~] # service httpd restartStopping httpd: [OK] Starting httpd: [OK]

Open a web page for testing

Now test whether memcache is installed and configured. Be sure to refresh it twice during the test.

If string (37) "TEST | php 1407375446 / TEST3 | iVera 1407376026 is installed successfully, otherwise the page will be refreshed again. If bool (false) still appears, then there is a problem with php configuration, because memcache module is not loaded in php (can be viewed using / webserver/php/bin/php-m | grep memcache, or there is a problem with session configuration)

Thank you for reading this article carefully. I hope the article "CentOS 6.5 how to compile and install PHP 5.4.25" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report