怎样在Linux下安装独立PHP环境

admin 提交于 周三, 06/10/2020 - 09:14

此方法允许同时安装多个PHP版本。

安装:

 

$ sudo apt install autoconf build-essential curl libtool   libssl-dev libcurl4-openssl-dev libxml2-dev libreadline-dev libzip-dev openssl   pkg-config zlib1g-dev libsqlite3-dev libonig-dev libpng-dev

$ ./configure --prefix=/var/www/php-7.4.6     --enable-mysqlnd     --with-pdo-mysql     --with-pdo-mysql=mysqlnd    --enable-bcmath     --enable-fpm     --with-fpm-user=www-data     --with-fpm-group=www-data     --enable-mbstring     --enable-phpdbg     --enable-shmop     --enable-sockets     --enable-sysvmsg     --enable-sysvsem     --enable-sysvshm     --with-zip   --with-zlib     --with-curl     --with-pear     --with-openssl     --enable-pcntl     --with-readline --enable-gd --enable-calendar

$ make

$ make install

配置php.ini: 

$ cp php.ini-production /var/www/php-7.4.6/lib/php.ini

change follow line in php.ini:

pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock

zend_extension=opcache.so

配置php-fpm: 

$ cd /var/www/php-7.4.6/etc;
$ cp php-fpm.conf.default php-fpm.conf
$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf

change port from 9000 to 9001 in php-fpm.d/www.conf if you are running more than one php-fpm.

$ sudo /var/www/php-7.4.6/sbin/php-fpm

配置nginx:

    

    location ~ ^/test/drupal9/.*\.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9001;
    }
 

参考:

https://www.php.net/manual/en/install.unix.debian.php#122244

添加新评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"汉语"