lnmp一鍵安裝包,安裝多版本php,並開啟redis與swoole


安裝多版本的php

sudo ./install.sh mphp
Install ZendGuardLoader for PHP 7.1...
unavailable now.
Write ZendGuardLoader to php.ini...
Creating new php-fpm configure file...
Copy php-fpm init.d file...
Add php-fpm7.1 service at system startup...
insserv: script php-fpm7.1: service php-fpm already provided!
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Starting LNMP...
Starting nginx...  done
Starting mysql (via systemctl): mysql.service.
Starting php-fpm  done
Starting php-fpm  done
===========================================
You have successfully install php-7.1.7 
===========================================

這個時候,你會發現,系統中已經有了多個php

$ whereis php
php: /usr/bin/php /usr/local/php /usr/local/php7.1

具體如何使用,還是要看nginx如何配置。

這里面多了一個enable-php7.1.conf

我們創建nginx 的vhost配置時,設置為7.1就可以了,例如

server
    {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;
        server_name jiqing.php7proj.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/php7proj;

        #error_page   404   /404.html;
        include enable-php7.1.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

重新啟動lnmp

sudo lnmp restart
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx...  done
[ ok ] Stopping mysql (via systemctl): mysql.service.
Gracefully shutting down php-fpm . done
Gracefully shutting down php-fpm . done
Starting LNMP...
Starting nginx...  done
[ ok ] Starting mysql (via systemctl): mysql.service.
Starting php-fpm  done
Starting php-fpm  done

這個時候,就可以了。

這樣就兩個都可以使用了!

為php7安裝redis擴展。

1.下載

sudo wget https://pecl.php.net/get/redis-4.0.2.tgz

2.解壓

sudo tar -zxvf redis-4.0.2.tgz 

3.通過phpize初始化

whereis phpize
phpize: /usr/bin/phpize
root@Ubuntu:/opt/redis-4.0.2# sudo /usr/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

4.安裝

sudo ./configure --with-php-config=/usr/local/php7.1/bin/php-config

5.make

# make
# make test

Build complete.
Don't forget to run 'make test'.


+-----------------------------------------------------------+
|                       ! ERROR !                           |
| The test-suite requires that proc_open() is available.    |
| Please check if you disabled it in php.ini.               |
+-----------------------------------------------------------+

make test 報錯,修改php.ini,去除proc_open限制。

然后繼續make test ,沒問題了。

6.make install

7.添加php.ini中

extension=redis.so

可以了,重啟一下lnmp。

繼續安裝swoole擴展!

1.下載

 wget https://github.com/swoole/swoole-src/archive/v2.2.0.tar.gz

2.解壓

tar -zvxf v2.2.0.tar.gz 

3.phpize初始化

root@Ubuntu:/opt/swoole-src-2.2.0# /usr/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

4.安裝

sudo ./configure --with-php-config=/usr/local/php7.1/bin/php-config

關閉proc_get_status

5.make && make test

6.make install

7.配置添加php.ini中

extension=swoole.so

重啟lnmp


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM