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

安裝多版本的phpphp

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 
===========================================

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

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

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

這裏面多了一個enable-php7.1.confmysql

咱們建立nginx 的vhost配置時,設置爲7.1就能夠了,例如nginx

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;
    }

從新啓動lnmpgit

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

這個時候,就能夠了。github

這樣就兩個均可以使用了!redis

爲php7安裝redis擴展。sql

1.下載swoole

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

相關文章
相關標籤/搜索