search
HomeBackend DevelopmentPHP ProblemLinux php 5.5 installation and configuration method

Linux php5.5 installation and configuration method: first download the PHP source package; then add the epel source and create the www user; then compile and install "/usr/local/src/php-5.5.15/"; Finally configure PHP.

Linux php 5.5 installation and configuration method

Recommended: "PHP Video Tutorial"

php5.5 Compilation and Installation

System environment: centos6.5

PHP package: 5.5.15

https://wiki.swoole.com/wiki/page/177.html

Download PHP source package

wget http://cn2.php.net/distributions/php-5.5.15.tar.bz2

tar xf php-5.5.15.tar.bz2 -C /usr/local/src/

Configuration file: /usr/local/php/etc/php-fpm.conf

Configuration pid: /var/run/php-fpm/ php-fpm.pid

Error log: error_log=/var/log/php-fpm.log

/etc/php.ini

Add epel source

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel
openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel

Create www user

groupadd www
useradd -g www -s /sbin/nologin -M www

Compile and install

cd /usr/local/src/php-5.5.15/
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=/usr/local/mysql \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-readline \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear

Your Web Server

Please add something like:

--with-apxs2=/usr/local/apache/bin/apxs 参数
--prefix=/usr/local/php \            安装路径
--with-config-file-path=/etc \        php.ini配置文件路径
--enable-inline-optimization \        优化项
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \                    启用 opcache,默认为 ZendOptimizer+(ZendOpcache)
--enable-fpm \                        FPM
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \                 MySQL
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \                    国际化与字符编码支持
--enable-mbstring \
--with-iconv \
--with-mcrypt \                        加密扩展
--with-mhash \
--with-openssl \
--enable-bcmath \                    数学扩展
--enable-soap \                         Web 服务,soap 依赖 libxml
--with-libxml-dir \
--enable-pcntl \                    进程,信号及内存
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \                    socket & curl
--with-curl \
--with-zlib \                        压缩与归档
--enable-zip \
--with-bz2 \
--with-readline \                    GNU Readline 命令行快捷键绑定
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear                            更多 PHP 扩展与应用库

Compile and install

 make -j4
 make install

Reinstall:

# make clean
# make clean all
# ./configure ...
# make -j4
# make install

Configure PHP

Configuration file

# cp php.ini-development /etc/php.ini

php-fpm service

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm

Start php-fpm

# service php-fpm start
Starting php-fpm  done
vi ~/.bash_profile
PATH=$PATH:$HOME/bin

and change it to:

PATH=$PATH:$HOME/bin:/usr/local/php/bin

Make the PHP environment variable take effect: # . ~/.bash_profile

Check the PHP version: php -v

Set auto-start at boot

echo service php-fpm start >> /etc/rc.local

rc.local may also appear in the directory of /etc/init.d

Add yum source

CentOS 6.x Source

# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Install PHP

# yum install --enablerepo=remi,remi-php56 php php-opcache php-pecl-apcu php-devel
php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug
php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process
php-gd php-common

Install version 5.6 as remi-php56, install version 5.5 as remi-php55

How to configure php-fpm as a service in Linux

1. Configure php-fpm.conf

vi /usr/local/php/etc/php-fpm.conf

php-fpm.pid directory must point to:/usr/local/php/var/run/php-fpm.pid

2. Copy the php-fpm script to the /etc/init.d directory

cp /home/soft/php-5.3.15/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

3. Set permissions and start php-fpm:

chmod 755 /etc/init.d/php-fpm
/etc/init.d/php-fpm start
chkconfig –add php-fpm

Finally, give php-fpm to serve Start, stop and restart in the following ways:

service php-fpm start
service php-fpm stop
service php-fpm reload

View version information

php -v

php install bcmath module

1 yum -y install php- bcmath

  find / -name bcmath.so

2 Find the php configuration file

php -i |grep php.ini

and add the code: extension=bcmath.so

3 Run php-m If

php warning: Module 'bcmath' already loaded in unknow on line 0

appears The bcmath module has been loaded multiple times, so step 2 is no longer needed.

Encountered failure to install the repository file:

Install a higher version of php: use the yum source, enable remi-php56, and an error is reported when installing the extension:

1 yum -y install php-gd --skip-broken

2 yum source problem, the selected yum source and system version are not compatible

yum clean all
rpm --rebuilddb
yum update

Or change the yum source

yum install php-gd --enablerepo=remi-php56

The above is the detailed content of Linux php 5.5 installation and configuration method. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools