Table of Contents
Download the source code and unzip it
Configure compilation parameters
Generate configuration file
Configuration
Compile and install PHP7
View the PHP7 directory after successful installation
Set up PHP7 configuration file
Set environment variables
Set the PHP log directory and php-fpm process file (php-fpm.sock) directory
Set PHP to start at boot
Start PHP service
Home php教程 php手册 [Installing PHP] How to compile and install PHP7 under openSUSE42.1

[Installing PHP] How to compile and install PHP7 under openSUSE42.1

Jul 06, 2016 pm 01:31 PM
php php7 Install compile

First of all, I recommend an article php 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog. It talks about whether I will use PHP7. Personally, I will use it without hesitation, but the production environment is not my decision, so I can only update the PHP version in my own development environment. So, what about you?

First of all, I recommend an article php 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog.

It talks about whether I will use PHP7. Personally, I will use it without hesitation, but I don’t have the final say in the production environment, so I can only update the PHP version in my own development environment. . So, what about you?

The author is using the openSUSE42.1 distribution of Linux. There is no installation package for PHP7 in Yast, so I can only compile and install it manually. As a PHP developer, I really hope to learn how to compile and install PHP7. I have tried it several times before, but every time I install it, I have to go online to find various information. So, after the successful installation this time, I want to go through my own installation process. And record the problems encountered so that you can refer to them later and share them with those who need them.

Download the source code and unzip it

Getting to the point, to compile and install PHP7, you must first download the source code of PHP7. You can clone it on github or download it from the PHP official website. After downloading, extract it to the /usr/local/src directory and rename the directory to php7. Enter the directory.

Configure compilation parameters

Generate configuration file

./buildconf
Copy after login

Configuration

./<span style="color: #000000;">configure \
</span>--PRefix=/usr/local/<span style="color: #000000;">php7 \
</span>--exec-prefix=/usr/local/<span style="color: #000000;">php7 \
</span>--bindir=/usr/local/php7/<span style="color: #000000;">bin \
</span>--sbindir=/usr/local/php7/<span style="color: #000000;">sbin \
</span>--includedir=/usr/local/php7/<span style="color: #000000;">include \
</span>--libdir=/usr/local/php7/lib/<span style="color: #000000;">php \
</span>--mandir=/usr/local/php7/php/<span style="color: #0000ff;">man</span><span style="color: #000000;"> \
</span>--with-config-<span style="color: #0000ff;">file</span>-path=/usr/local/php7/<span style="color: #000000;">etc \
</span>--with-MySQL-sock=/var/run/mysql/<span style="color: #000000;">mysql.sock \
</span>--with-mcrypt=/usr/<span style="color: #000000;">include \
</span>--with-<span style="color: #000000;">mhash \
</span>--with-<span style="color: #000000;">openssl \
</span>--with-mysqli=<span style="color: #000000;">shared,mysqlnd \
</span>--with-pdo-mysql=<span style="color: #000000;">shared,mysqlnd \
</span>--with-<span style="color: #000000;">gd \
</span>--with-<span style="color: #000000;">iconv \
</span>--with-<span style="color: #000000;">zlib \
</span>--enable-<span style="color: #0000ff;">zip</span><span style="color: #000000;"> \
</span>--enable-inline-<span style="color: #000000;">optimization \
</span>--disable-<span style="color: #000000;">debug \
</span>--disable-<span style="color: #000000;">rpath \
</span>--enable-<span style="color: #000000;">shared \
</span>--enable-<span style="color: #000000;">xml \
</span>--enable-<span style="color: #000000;">bcmath \
</span>--enable-<span style="color: #000000;">shmop \
</span>--enable-<span style="color: #000000;">sysvsem \
</span>--enable-<span style="color: #000000;">mbregex \
</span>--enable-<span style="color: #000000;">mbstring \
</span>--enable-<span style="color: #0000ff;">ftp</span><span style="color: #000000;"> \
</span>--enable-gd-native-<span style="color: #000000;">ttf \
</span>--enable-<span style="color: #000000;">pcntl \
</span>--enable-<span style="color: #000000;">sockets \
</span>--with-<span style="color: #000000;">xmlrpc \
</span>--enable-<span style="color: #000000;">soap \
</span>--without-<span style="color: #000000;">pear \
</span>--with-<span style="color: #000000;">gettext \
</span>--enable-<span style="color: #000000;">session \
</span>--with-<span style="color: #000000;">curl \
</span>--with-jpeg-<span style="color: #0000ff;">dir</span><span style="color: #000000;"> \
</span>--with-freetype-<span style="color: #0000ff;">dir</span><span style="color: #000000;"> \
</span>--enable-<span style="color: #000000;">opcache \
</span>--enable-<span style="color: #000000;">fpm \
</span>--disable-<span style="color: #000000;">cgi \
</span>--with-fpm-user=<span style="color: #000000;">nginx \
</span>--with-fpm-group=<span style="color: #000000;">nginx \
</span>--without-<span style="color: #000000;">gdbm \
</span>--disable-fileinfo
Copy after login

Parameter description

prefix root directory of PHP7 installation

with-config-file-path PHP7 configuration file directory

The result after executing the above configuration command is as shown below:

When executing the above command, you will encounter some prompts about missing dependencies. The dependency problems I encountered are listed below:

Error:

configure: error: xml2-config not found. Please check your libxml2 installation.
Copy after login

Solution:

zypper <span style="color: #0000ff;">install</span> libxml2-devel
Copy after login

Error:

configure: WARNING: unrecognized options: --with-mysql
Copy after login

Solution:

取消这个选项,这个选项是不存在的
Copy after login

Error:

configure: error: jpeglib.h not found.
Copy after login

Solution:

zypper <span style="color: #0000ff;">install</span> libjpeg-devel
Copy after login

Error:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Copy after login

Solution:

zypper <span style="color: #0000ff;">install</span> libmcrypt-devel
Copy after login

Error:

checking <span style="color: #0000ff;">for</span><span style="color: #000000;"> recode support... yes
configure: error: Can not </span><span style="color: #0000ff;">find</span> recode.h anywhere under /usr /usr/local /usr /opt.
Copy after login

Solution:

zypper <span style="color: #0000ff;">install</span> librecode-devel
Copy after login

In general, when configuring, if you encounter something that is not available, open Yast and search for it. If it exists, install it, and then recompile to see what else is needed. If you can’t find it in Yast, then search online on Google .

Compile and install PHP7

<span style="color: #0000ff;">make</span> && <span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>
Copy after login

Among them, you can choose make test after make. It's just an optional step. I don't know if there will be any problems if you don't execute it, but I haven't encountered it yet.

View the PHP7 directory after successful installation

After successful compilation and installation, check the PHP7 installation directory `ls /usr/local/php7`:

Set up PHP7 configuration file

<span style="color: #0000ff;">cp</span> /usr/local/src/php7/php.ini-production /usr/local/php7/etc/<span style="color: #000000;">php.ini
</span><span style="color: #0000ff;">cp</span> /usr/local/src/sapi/fpm/init.d.php-fpm /etc/init.d/php-<span style="color: #000000;">fpm
</span><span style="color: #0000ff;">cp</span> /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-<span style="color: #000000;">fpm.conf
</span><span style="color: #0000ff;">cp</span> /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
Copy after login

Set environment variables

Add

to the last line of the /etc/profile file
export PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH
Copy after login


Then execute source /etc/profile

Set the PHP log directory and php-fpm process file (php-fpm.sock) directory

<span style="color: #0000ff;">mkdir</span> -p /var/log/php-fpm/ && <span style="color: #0000ff;">mkdir</span> -p /var/run/php-fpm && cd /var/run/ && <span style="color: #0000ff;">chown</span> -R nginx:nginx php-fpm
Copy after login

Set PHP to start at boot

<span style="color: #0000ff;">chmod</span> +x /etc/init.d/php-<span style="color: #000000;">fpm
chkconfig php</span>-fpm on
Copy after login

You can use the chkconfig command to view the list of startup services.

Start PHP service

service php-fpm start
Copy after login

Check whether PHP is started successfully through ps aux | grep 'php'

At this point, PHP7 has been installed successfully, and you can start using PHP7!


Statement of this Website
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

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles