微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Ubuntu 14.04上安装php7(zts)pthreads

我需要帮助完整安装 PHP7(ZTS)Pthreads.我尝试了以下安装,但无法使其正常工作.
sudo -i

apt-get update

apt-get install -y git bison autoconf build-essential pkg-config gitcore libltdl-dev libbz2-dev libxml2-dev libxslt1-dev libssl-dev libicu-dev libpspell-dev libenchant-dev libmcrypt-dev libpng-dev libjpeg8-dev libfreetype6-dev libMysqLclient-dev libreadline-dev libcurl4-openssl-dev

mkdir /etc/PHP7

mkdir /etc/PHP7/cli

cd /usr/local/src

git clone https://github.com/PHP/PHP-src.git --depth=1

cd PHP-src/ext

git clone https://github.com/krakjoe/pthreads -b master pthreads

cd ..

./buildconf --force

PHP_configure_args="--prefix=/etc/PHP7 --with-config-file-path=/etc/PHP7/cli --with-config-file-scan-dir=/etc/PHP7/cli/conf.d --with-bz2 --with-zlib --enable-zip --with-mcrypt --with-openssl --with-curl --enable-ftp --with-MysqLi --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath --enable-mbstring --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-maintainer-zts --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-cli --enable-pthreads=shared --with-tsrm-pthreads"


./configure $PHP_configure_args 

make && make install

cd /usr/local/src/PHP-src/ext/intl*

chmod a+x /etc/PHP7/bin/PHP-config

chmod a+x /etc/PHP7/bin/PHPize

/etc/PHP7/bin/PHPize

./configure --enable-intl --with-icu-dir=/usr  --prefix='/etc/PHP7' --with-libdir='/lib/x86_64-linux-gnu' --with-PHP-config='/etc/PHP7/bin/PHP-config'

make && make install

cp /usr/local/src/PHP-src/PHP.ini-production /etc/PHP7/cli/PHP.ini

ln --symbolic /etc/PHP7/bin/PHP /usr/bin/PHP

ln --symbolic /etc/PHP7/sbin/PHP-fpm /usr/sbin/PHP7-fpm

echo 'zend_extension=opcache.so' >> /etc/PHP7/cli/PHP.ini

echo 'extension=pthreads.so' >> /etc/PHP7/cli/PHP-cli.ini

echo "extension=intl.so" >> /etc/PHP7/cli/PHP.ini

FPM配置. 1)/etc/init.d/PHP7-fpm

#!/bin/sh
### BEGIN INIT INFO
# Provides:          PHP-fpm PHP7-fpm
# required-Start:    $remote_fs $network
# required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts PHP7-fpm
# Description:       Starts The PHP FastCGI Process Manager Daemon
### END INIT INFO

# Author: Ondrej Sury <ondrej@debian.org>
# Adapted to PHP7-fpm by @bjornjohansen

PATH=/usr/sbin
DESC="PHP7 FastCGI Process Manager"
NAME=PHP7-fpm
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--daemonize --fpm-config /etc/PHP7/etc/PHP-fpm.conf"
PIDFILE=/var/run/PHP7-fpm.pid
TIMEOUT=30
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Don't run if we are running upstart
if init_is_upstart; then
    exit 1
fi

#
# Function to check the correctness of the config file
#
do_check()
{
    /usr/local/lib/PHP7-fpm-checkconf || return 1
    return 0
}

#
# Function that starts the daemon/service
#
do_start()
{
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running  
    #   2 if daemon Could not be started  
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec          $DAEMON --test > /dev/null \
            || return 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
            $DAEMON_ARGS 2>/dev/null \
            || return 2
    # Add code here,if necessary,that waits for the process to be ready
    # to handle requests from services started subsequently which depend
    # on this one.  As a last resort,sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon Could not be stopped
    #   other if a failure occurred
    start-stop-daemon --stop --quiet --retry=QUIT/$TIMEOUT/TERM/5/KILL/5 --pidfile $PIDFILE --name $NAME
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other    code
    # that waits for the process to drop all resources that Could be
    # needed by services started subsequently.  A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --   retry=0/30/TERM/5/KILL/5 --exec $DAEMON
    [ "$?" = 2 ] && return 2
    # Many daemons don't delete their pidfiles when they exit.
    rm -f $PIDFILE
    return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    #
    # If the daemon can reload its configuration without
    # restarting (for example,when it is sent a SIGHUP),# then implement that here.
    #
    start-stop-daemon --stop --signal USR2 --quiet --pidfile $PIDFILE --name $NAME
    return 0
}

case "$1" in
start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_check $VERBOSE
    case "$?" in
        0)
            do_start
            case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
            esac
            ;;
        1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
            0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
check)
    do_check yes
    ;;
reload|force-reload)
    log_daemon_msg "Reloading $DESC" "$NAME"
    do_reload
    log_end_msg $?
    ;;
reopen-logs)
    log_daemon_msg "Reopening $DESC logs" $NAME
    if start-stop-daemon --stop --signal USR1 --oknodo --quiet \
        --pidfile $PIDFILE --exec $DAEMON
    then
        log_end_msg 0
    else
        log_end_msg 1
    fi
    ;;
restart)
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
            do_start
            case "$?" in
                    0) log_end_msg 0 ;;
                    1) log_end_msg 1 ;; # Old process is still running
                    *) log_end_msg 1 ;; # Failed to start
            esac
            ;;
      *)
            # Failed to stop
            log_end_msg 1
            ;;
    esac
    ;;
*)
    echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-  reload}" >&2
    exit 1
;;
esac

chmod a x /etc/init.d/PHP7-fpm

2)/etc/init/PHP7-fpm.conf

# PHP7-fpm - The PHP FastCGI Process Manager
# Original script by Ondřej Surý. Adapted to PHP7-fpm by @bjornjohansen

description "The PHP FastCGI Process Manager"
author "Ondřej Surý <ondrej@debian.org>"

start on runlevel [2345]
stop on runlevel [016]

# Precise upstart does not support reload signal,and thus rejects the
# job. We'd rather start the daemon,instead of forcing users to
# reboot https://bugs.launchpad.net/ubuntu/+source/PHP5/+bug/1272788
#
# reload signal USR2


pre-start exec /usr/local/lib/PHP7-fpm-checkconf

respawn
exec /usr/sbin/PHP7-fpm --nodaemonize --fpm-config /etc/PHP7/etc/PHP-fpm.conf

3)/usr/local / lib / PHP7 -fpm-checkconf

#!/bin/sh
set -e
errors=$(/usr/sbin/PHP7-fpm --fpm-config /etc/PHP7/etc/PHP-fpm.conf -t 2>&1 | grep "\[ERROR\]" || $
if [ -n "$errors" ]; then
    echo "Please fix your configuration file..."
    echo $errors
    exit 1
fi
exit 0

chmod a x /usr/local / lib / PHP7 -fpm-checkconf

cp /etc/PHP7/etc/PHP-fpm.conf.default /etc/PHP7/etc/PHP-fpm.conf

cp /etc/PHP7/etc/PHP-fpm.d/www.conf.default /etc/PHP7/etc/PHP-fpm.d/www.conf

update-rc.d -f PHP7-fpm defaults

当我运行以下内容时收到错误消息“作业无法启动”

service PHP7-fpm start

如果有人能够纠正我的错误或提供完整安装的PHP7(ZTS)Pthreads,我将很高兴.

更新和安装依赖项
apt-get update

apt-get install -y bison autoconf build-essential pkg-config git-core libltdl-dev libbz2-dev libxml2-dev libxslt1-dev libssl-dev libicu-dev libpspell-dev libenchant-dev libmcrypt-dev libpng-dev libjpeg8-dev libfreetype6-dev libMysqLclient-dev libreadline-dev libcurl4-openssl-dev

删除任何现有的PHP7并重新创建PHP7和其他子目录

rm -rf /etc/PHP7

mkdir -p /etc/PHP7
mkdir -p /etc/PHP7/cli
mkdir -p /etc/PHP7/etc

删除当前工作目录中的所有PHP-src文件夹,然后从git branch重新安装

rm -rf PHP-src

git clone https://github.com/PHP/PHP-src.git --depth=1

将目录更改为ext以从git下载pthreads

cd PHP-src/ext

git clone https://github.com/krakjoe/pthreads -b master pthreads

回到PHP-src作为当前的工作目录

cd ..

构建PHP-src

./buildconf --force

设置适用于您自己案例的配置选项,启用zts,fpm和其他扩展

CONfigURE_STRING="--prefix=/etc/PHP7 --with-bz2 --with-zlib --enable-zip --disable-cgi \
   --enable-soap --enable-intl --with-mcrypt --with-openssl --with-readline --with-curl \
   --enable-ftp --enable-MysqLnd --with-MysqLi=MysqLnd --with-pdo-MysqL=MysqLnd \
   --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext \
   --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl \
   --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json \
   --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache \
   --with-pcre-regex --with-config-file-path=/etc/PHP7/cli \
   --with-config-file-scan-dir=/etc/PHP7/etc --enable-cli --enable-maintainer-zts \
   --with-tsrm-pthreads --enable-debug --enable-fpm \
   --with-fpm-user=www-data --with-fpm-group=www-data"

运行configure脚本并安装

./configure $CONfigURE_STRING

make && make install

使以下帮助程序可执行

chmod o+x /etc/PHP7/bin/PHPize

chmod o+x /etc/PHP7/bin/PHP-config

现在将目录更改为pthreads并运行PHPize

cd ext/pthreads*

/etc/PHP7/bin/PHPize

设置pthreads的配置选项,但要确保enable-pthreads = shared,这是配置的主要方面

./configure --prefix='/etc/PHP7' --with-libdir='/lib/x86_64-linux-gnu' \ 
    --enable-pthreads=shared --with-PHP-config='/etc/PHP7/bin/PHP-config'

make && make install

FPM安装涉及将配置文件复制到适当的位置,并在必要时进行更改.

#back to current working directory PHP-src

cd ../../

#PHP.ini to be used by fpm-fcgi

cp -r PHP.ini-production /etc/PHP7/cli/PHP.ini

sed -i 's/;date.timezone =.*/date.timezone = Africa\/Lagos/' /etc/PHP7/cli/PHP.ini

cp /etc/PHP7/etc/PHP-fpm.conf.default /etc/PHP7/etc/PHP-fpm.conf

cp /etc/PHP7/etc/PHP-fpm.d/www.conf.default /etc/PHP7/etc/PHP-fpm.d/www.conf

cp sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP7-fpm

sed -i 's/Provides:          PHP-fpm/Provides:          PHP7-fpm/' /etc/init.d/PHP7-fpm

sed -i 's#^PHP_fpm_BIN=.*#PHP_fpm_BIN=/usr/sbin/PHP7-fpm#' /etc/init.d/PHP7-fpm

sed -i 's#^PHP_fpm_CONF=.*#PHP_fpm_CONF=/etc/PHP7/etc/PHP-fpm.conf#' /etc/init.d/PHP7-fpm

sed -i 's#^PHP_fpm_PID=.*#PHP_fpm_PID=/var/run/PHP7-fpm.pid#' /etc/init.d/PHP7-fpm

将pthreads.so添加PHP-cli.ini,这将由命令行界面(CLI)使用

cp PHP.ini-production /etc/PHP7/cli/PHP-cli.ini

echo "extension=pthreads.so" > /etc/PHP7/cli/PHP-cli.ini

添加其他扩展和链接二进制文件

echo "zend_extension=opcache.so" >> /etc/PHP7/cli/PHP.ini

ln --symbolic /etc/PHP7/bin/PHP /usr/bin/PHP

ln --symbolic /etc/PHP7/sbin/PHP-fpm /usr/sbin/PHP7-fpm

chmod +x /etc/init.d/PHP7-fpm

update-rc.d PHP7-fpm defaults

service PHP7-fpm start

确保以下内容与/etc/PHP7/etc/PHP-fpm.conf中的相同

pid = /var/run/PHP7-fpm.pid
error_log = /var/log/PHP7-fpm.log
include=/etc/PHP7/etc/PHP-fpm.d/*.conf

确保以下内容与/etc/PHP7/etc/PHP-fpm.d/www.conf中的相同

user = www-data
group = www-data
listen = /var/run/PHP7-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
listen.allowed_clients = 127.0.0.1
security.limit_extensions = .PHP .PHP3 .PHP4 .PHP5 .PHP7

确保以下内容与/etc/PHP7/cli/PHP.ini中的相同

cgi.fix_pathinfo=1

要与Nginx一起使用,请在Nginx / sites-available / default中执行以下操作

upstream PHP7-fpm {
    server unix:/var/run/PHP7-fpm.sock;
}
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /usr/share/Nginx/html;

    # Add index.PHP to the list if you are using PHP
    index index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }
    location ~ [^/]\.PHP(/|$) {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
        fastcgi_pass PHP7-fpm;
        fastcgi_index index.PHP;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

service Nginx restart

要使用pthread,请记住它通过命令行界面工作.假设thread.PHP是你的并行编程代码,你不能通过在浏览器中使用localhost / path / to / thread.PHP在sapi / fpm模式下运行它

<?PHP
//thread.PHP
    class Part extends Threaded{ public function run(){} }
    $parts = new Part();

    for($i=0;$i<4;$i++) $parts[] = $i;
?>

而是通过命令行方法(如“system”)创建一个文件来执行代码thread.PHP

<?PHP
    system("PHP /path/to/thread.PHP");
?>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、安装SSH和配置SSH无密码登录四、安装Java环境1. 安装JDK2. 配置JDK环境3. 检验安装五、安装单机Hadoop1. 下载安装Hadoop2. 运行示例总结前言本文安装的 Hadoop 及 Java 环境基于林子雨老师的《大数据技术原理与应用(第3版)》中所要求,其中Java 版本为1.8.0_301,Hadoop 版本为3.3.1,其他版本的安装请参考其他博客。..
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html  运行django出现错误信息:[2016-02-16 14:33:24,476 pyinotify ERROR] add_watch: cannot watch /usr/local/lib/python2.7/dist-packages/django/contrib/sessio...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失了,如下:别着急,以下教你如何找回之前的虚拟机:1、点击控制,然后选择注册,找到虚拟机的安装目录,比如:C:UserstxVirtualBox VMs,然后选择需要找回的虚拟机vbox,点击打开按钮即可:2、如果打开后报错,则执行第三步:3、删除ubuntu.vbox,然后将ubuntu.vbox-prev重命名为ubuntu.vbox,然后再执行第二步即可...
参见:https://blog.csdn.net/weixin_38883338/article/details/82153933 https://blog.csdn.net/github_39533414/article/details/85211012
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netplan 基于 YAML 的配置系统,使得配置过程非常简单。Netplan 替换了我们之前在 Ubuntu 中用于配置网络接口的旧配置文件/etc/network/interfaces。在本文中,我们将学习如何使用 Netplan 在 Ubuntu 中配置网络。我们将看到静态和动态 IP 配置。我将使用 Ubuntu 18.04 LTS 来描述本文中提到的过程。使用 Netplan 配置网络您可以在/etc
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问,该 URL 代表一种“替代名称”,用于标识提供该服务的服务器的 IP 地址和端口。同一台机器可以同时在不同的端口上提供不同的服务。出于安全原因,可能需要屏蔽 Web 服务的端口号,从而在外部显示与服务实际侦听的端口号不对应的端口号。感谢本教程,您将能够管理您的服务器端口,配置集成在 Ubuntu 中的 UFW 防火墙。特别是,按照指南的说明,您将学习将来自某个端口的请求转发到另一个端口(端口转发),同时使用后者提供的.
Observium 是一个免费和开源的 sa 网络管理和监控系统工具。我们可以使用 SNMP 收集数据,它允许监控所有网络设备。它提供了一个简单易用的 Web 界面。它基于 PHP 并使用 MySQL 数据库来存储数据。在 ubuntu 上设置 Observium 有几个步骤:第 1 步:更新系统。apt-get update第 2 步:安装 PHP 和模块。apt install wget apache2 php php-{pear,cgi,common,curl,mbstring,g
从 20.04 开始,Ubuntu 决定更新实时服务器安装程序以实现自动安装规范,以便能够仅使用 Subiquity 完全自动化安装过程。Subiquity 是新的服务器安装程序(又名“服务器无处不在”),旨在取代之前基于 debian-installer 的经典系统。本文说明了如何使用 Packer 和 Proxmox 上的 Subiquity 生成 Ubuntu Server 20.04 图像模板。介绍Subiquity 仅在live图像文件版本中可用(例如ubuntu-20.0...
Ubuntu 将停止支持 Debian 安装程序(预置)。Ubuntu Server 20.04 附带了一种新的自动化操作系统安装方法,称为带有 subiquity 服务器安装程序的自动安装。这篇文章展示了使用新安装程序构建的打包程序。此设置仅适用于 Ubuntu-20.04 live-server 而不是旧版。SubiquitySubiquity 是 Ubuntu 服务器的新自动安装程序,它是在 18.04 中引入的。自动安装的设置由 cloud-init 配置提供。如果设置,将从配置文件.
此页面的目的是提供在您机器上的 VM 中执行自动安装的简单说明。此页面假设您使用的是 amd64 架构。s390x也有一个版本。通过网络提供自动安装数据这种方法是最容易推广到完全基于网络的安装的方法,在这种安装中,机器会进行网络引导,然后自动安装。下载 ISO转到20.04 ISO 下载页面并下载最新的 Ubuntu 20.04 实时服务器 ISO。挂载 ISOsudo mount -r ~/Downloads/ubuntu-20.04-live-server-amd64...