This article describes how to compile and install PHP7 in openSUSE42.1. If you need it, please refer to the following article. PHP 7 Release Date Arrived: Will Developers Adopt PHP 7? -PHP Classes blog.
I personally don't hesitate to use PHP7, but the production environment is not my final say, therefore, you can only update the PHP version in your own development environment. What about you?
I am using the openSUSE42.1 release of Linux, and there is no PHP7 installation package in Yast, so I can only manually compile and install it myself. As a PHP developer, I very much hope to learn how to compile and install PHP7. I tried it several times before, but I had to go online to find various materials for each installation, after the installation is successful, you will want to record your installation process and problems, so that you can easily view and share the installation process with those who need it later.
Download and decompress the source code
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. Download the package, decompress it to the/usr/local/src directory, and rename it php7. Enter the directory.
Configure compilation Parameters
Generate configuration file
./Buildconf
Configuration
./configure \--prefix=/usr/local/php7 \--exec-prefix=/usr/local/php7 \--bindir=/usr/local/php7/bin \--sbindir=/usr/local/php7/sbin \--includedir=/usr/local/php7/include \--libdir=/usr/local/php7/lib/php \--mandir=/usr/local/php7/php/man \--with-config-file-path=/usr/local/php7/etc \--with-mysql-sock=/var/run/mysql/mysql.sock \--with-mcrypt=/usr/include \--with-mhash \--with-openssl \--with-mysqli=shared,mysqlnd \--with-pdo-mysql=shared,mysqlnd \--with-gd \--with-iconv \--with-zlib \--enable-zip \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-xml \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache \--enable-fpm \--disable-cgi \--with-fpm-user=nginx \--with-fpm-group=nginx \--without-gdbm \--disable-fileinfo
Parameter description
Prefix PHP7 installation root directory
With-config-file-path PHP7 configuration file directory
The result of executing the preceding configuration command is as follows:
When you execute the preceding command, you will encounter some missing dependencies. The following lists the dependencies I encountered:
Error:
Configure: error: xml2-config not found. Please check your libxml2 installation.
Solution:
Zypper install libxml2-devel
Error:
Configure: WARNING: unrecognized options: -- with-mysql
Solution:
Cancel this option. This option does not exist.
Error:
Configure: error: Invalid Lib. h not found.
Solution:
Zypper install libjpeg-devel
Error:
Configure: error: mcrypt. h not found. Please reinstall libmcrypt.
Solution:
Zypper install libmcrypt-devel
Error:
Checking for recode support... yes
Configure: error: Can not find recode. h anywhere under/usr/local/usr/opt.
Solution:
Zypper install librecode-devel
In general, if no Yast is available during configuration, you can search for Yast. If yes, install Yast and re-compile it. If Yast cannot be found, search for Google online.
Compile and install PHP7
Make & make install
After make, you can select make test. It's only an optional step. I don't know what the problem is, but I haven't encountered it yet.
View the PHP7 directory after successful installation
After compilation and installation are successful, check the PHP7 installation directory 'ls/usr/local/php7 ':
Set the PHP7 configuration file
Cp/usr/local/src/php7/php. ini-production/usr/local/php7/etc/php. ini
Cp/usr/local/src/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
Cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
Cp/usr/local/php7/etc/php-fpm.d/www. conf. default/usr/local/php7/etc/php-fpm.d/www. conf
Set Environment Variables
Add
Export PATH =/usr/local/php7/bin:/usr/local/php7/sbin: $ PATH
Then execute source/etc/profile
Set PHP log directory and php-fpm process file (php-fpm.sock) Directory
Mkdir-p/var/log/php-fpm/& mkdir-p/var/run/php-fpm & cd/var/run/& chown-R nginx: nginx php-fpm
Set PHP to boot
Chmod + x/etc/init. d/php-fpm
Chkconfig php-fpm on
You can run the chkconfig command to view the startup service list.
Start the PHP Service
Service php-fpm start
Run ps aux | grep 'php' to check whether php is successfully started.
So far, PHP 7 has been installed successfully. You can also start to use PHP7!
The above describes how to compile and install PHP7 in openSUSE42.1.