Table of Contents
Installation environment
Configuring the PHP environment
Compile PHP
Compile pthreads The critical moment has come
Configuring php.ini
Home Backend Development PHP Problem How to install php thread extension on linux

How to install php thread extension on linux

Oct 26, 2021 am 10:29 AM
pthreads ubuntu

How to install php thread extension on linux: 1. Find the lnmp.conf file in the lnmp installation directory; 2. Add "--enable-maintainer-zts" to "PHP_Modules_Options"; 3. Compile pthreads. Can.

How to install php thread extension on linux

The operating environment of this article: Ubuntu 16.04 system, PHP7.1 version, DELL G3 computer

How to install the php thread extension on Linux?

Ubuntu PHP installation pthreads extension:

pthreads is a PHP extension that uses multi-threading. I won’t introduce too much here. I believe that since you have already understood it, if you don’t understand, just read the documentation.

Document address: https://www.php.net/manual/zh/book.pthreads.php

Let’s talk about the installation process here. There are some twists and turns, and I also consulted a lot of information. , was officially installed. Write it down to keep your own record, and also give future friends a reference to avoid pitfalls.

Installation environment

  • Ubuntu 16.04 LTS
  • Lnmp 1.4 - - I believe many people are using this
  • pthreads source code

It should be noted here that this extension cannot be installed successfully through pecl install pthreads. You need to download the source code, compile and install it yourself, and it can only be downloaded from the GitHub trunk branch. Other source codes seemed to have problems. I first downloaded them from http://pecl.php.net, but the compilation always failed. Later, I checked the information and found that there was a problem. You need to download it from GitHub.

GitHub: https://github.com/krakjoe/pthreads

Configuring the PHP environment

By default, everyone has already installed the lnmp environment. If it is not installed properly, please turn left when you go out and Google it.
Because pthreads requires PHP to run in a thread-safe manner, you need to add --enable-maintainer-zts when compiling PHP. However, the lnmp integration package is thread-unsafe by default.

Here go to your lnmp installation directory and find a lnmp.conf file

How to install php thread extension on linux

Add --enable-maintainer-zts in PHP_Modules_Options, just like my screenshot .

Compile PHP

  1. New installation environment, just follow the lnmp process step by step. After the installation is complete, php is thread-safe.
  2. Installed lnmp environment Here we can use the upgrade script provided by lnmp to upgrade php (PS: The script does not detect the current version number. If we enter the current version number, Just reinstall PHP) The operation is completed.
  3. ** Manually compile PHP ** Enter the lnmp1.4-full/src directory (according to your actual situation), my directory is in /home/src/lnmp1.4-full/src and see if there is any PHP compressed package, if you haven’t downloaded one yourself
sudo wget http://cn2.php.net/distributions/php-7.0.20.tar.bz2
tar -jxvf php-7.0.20.tar.bz2
Copy after login

Note: You can get the address by yourself from the PHP official website. What I give here is currently available.

Continue:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl --enable-maintainer-zts
make
sudo make install
Copy after login

This code is extracted from lnmp1.4-full/include/php.sh. You can study it yourself.
Open phpinfo();

How to install php thread extension on linux

Confirm that Thread Safety is enabled.

Compile pthreads The critical moment has come

Compile pthreads The source code package is placed in the ext directory of the php source code. My directory is: lnmp1.4-full\src\php-7.0.19\ext [Adjust according to your own situation]
Enter the pthreads directory

phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
sudo make install
Copy after login

php-config path is adjusted according to your own situation. If you are using the default lnmp, this is it

When executed here, a message indicating that pthreads.so was successfully compiled should appear. If not, check the previous steps.

Configuring php.ini

General online tutorials will say after reaching this point: Add pthreads.so to the php.ini file and restart php-fpm and that's it.
This is a pit. If you add php.ini directly, you will find that php-fpm cannot be started, and it prompts that pthreads.so cannot be loaded.

Correct posture:
Copy php.ini and name it php-cli.ini
Put pthreads.so into php.cli.ini
Then php -m | grep pthreads to see if it has appeared.

It is complete only at this point.

Note: Do not use pthreads in a production environment If there are bugs, just play with it yourself and run command line tasks. Through the final installation, you also discovered that it can only be run through the cli. Ha ha ha ha.

Finally, a reminder, there are many demos in the windows installation pthreads package that you can view.

Windows version download address: https://windows.php.net/downloads/pecl/releases/pthreads/

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to install php thread extension on linux. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
How to cancel the lock icon in the lower right corner of the Ubuntu 18.04 folder? How to cancel the lock icon in the lower right corner of the Ubuntu 18.04 folder? Jan 12, 2024 pm 11:18 PM

In the Ubuntu system, we often encounter folders with a lock shape on the top. This file often cannot be edited or moved. This is because there is no permission to edit the file, so we need to modify its permissions. How to remove the lock in the lower right corner? Let’s take a look at the detailed tutorial below. 1. Right-click on the locked folder--Properties. 2. Select the permissions option in the window. 3. Select everything inside to create and delete files. 4. Then select Change the permissions of the included files at the bottom, which are also set to create and delete files. Finally, remember to click Change in the upper right corner. 5. If the above lock is still not removed, or the options are grayed out and cannot be operated, you can right-click inside - open the terminal. 6. make

What should I do if the Ubuntu terminal cannot be opened? How to fix the problem that Ubuntu cannot open the terminal What should I do if the Ubuntu terminal cannot be opened? How to fix the problem that Ubuntu cannot open the terminal Feb 29, 2024 pm 05:30 PM

It is a very common problem these days that Ubuntu does not allow its users to open the terminal. If you receive a similar issue and don’t know what to do next, learn about five fixes on how to resolve this “Ubuntu cannot open terminal” issue on your Linux device. Without further ado, let’s dive into what causes it and the solutions available to it. Why can't Ubuntu open the terminal on it? This mainly happens when you install some defective software or modify the terminal configuration. In addition to this, new applications or games that interact with locales and corrupt them can cause similar problems. Some users reported a fix for this issue when searching for Terminal in Ubuntu's activity menu. This shows that

How to remove icons in Ubuntu start menu? How to remove icons in Ubuntu start menu? Jan 13, 2024 am 10:45 AM

There are many software icons listed in the Ubuntu system start menu. There are many uncommon icons. If you want to delete them, how should you delete them? Let’s take a look at the detailed tutorial below. 1. First enter the ubuntu desktop and click on the start menu under the left panel. 2. You can find a text editor icon inside, we need to delete it. 3. Now we return to the desktop and right-click the mouse to open the terminal. 4. Use the command to open the application list directory. sudonautilus/usr/share/applicationssudonautilus~/.local/share/applications5. Find the corresponding text editor icon inside. 6. Then go straight

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

A sneak peek of the seven highlights of Ubuntu 24.04 LTS A sneak peek of the seven highlights of Ubuntu 24.04 LTS Feb 27, 2024 am 11:22 AM

Ubuntu24.04LTS, codenamed "NobleNumbat" will be released soon! If you are using a non-LTS version such as Ubuntu 23.10, sooner or later you will need to consider upgrading. For those using Ubuntu20.04LTS or Ubuntu22.04LTS, it is worth thinking about whether to upgrade. Canonical has announced that Ubuntu 24.04LTS will provide update support for up to 12 years, broken down as follows: As an LTS version, it will have 5 years of regular maintenance and security updates. If you subscribe to Ubuntu Pro, you can enjoy an additional 5 years of support. Currently, this additional support period has been extended to 7 years, which means you will get up to 12

Ubuntu 20.04 screen recording software OBS installation and uninstallation graphic tutorial Ubuntu 20.04 screen recording software OBS installation and uninstallation graphic tutorial Feb 29, 2024 pm 04:01 PM

OBS is open source software developed by volunteer contributors around the world in their free time. A video live recording software, mainly used for video recording and live streaming. Please note that when installing Ubuntu/Mint, OBSStudio cannot fully work on ChromeOS, and functions such as screen and window capture cannot be used. It is recommended to use xserver-xorg1.18.4 or newer version to avoid potential performance issues with certain features in OBS, such as full-screen projectors. FFmpeg is required. If you don't have FFmpeg installed (if you're not sure, you probably don't), you can get it with: sudoaptinstallffmpeg I already have it installed here

How to disable global menu in Ubuntu system? How to disable global menu in Ubuntu system? Jan 11, 2024 pm 04:33 PM

Starting from Ubuntu 11.04, a new feature has been added called the global menu, which is a common menu bar shared by all applications (shown above). Most of us have been used to each application window having its own menu bar. A global menu is available on the top panel of the Unity desktop, regardless of where the application window is. If the application window in the lower right corner of your screen is resized to small, the application's menu bar remains on the top panel. This can be confusing and uncomfortable if you're not used to it. This experience mainly refers to "This is How Linux Should Be Learned". If you don't like the new global menu and want to move the menu bar back to each application window, we will show you how to disable the global menu. 1. Press Ctrl+Al

Ubuntu finally supports disabling automatic updates of snap packages Ubuntu finally supports disabling automatic updates of snap packages Jan 13, 2024 am 10:09 AM

snap is a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and systemdinit system. These packages, known as snaps, and the tool that uses them, snapd, are available across a range of Linux distributions and allow upstream software developers to publish their applications directly to users. With snap, users can easily install Linux applications. By default, snapd will check for updates four times a day and automatically update snap applications to the latest version. While there are many ways to control when and how often updates are installed, users cannot completely turn off automatic updates for security reasons. Although the original intention of snap is good, many people use it to

See all articles