Linux配置yaf3.x.x环境

yaf3.x.x需要php7以上的环境。

第一步:配置php7

  • 找到lnmp安装包的位置

  • 执行命令

./install.sh mphp

这里面,我们选择PHP7.2

此时我们看,就会多一个php的文件夹

# whereis php
php: /usr/bin/php /usr/local/php /usr/local/php7.2

第二步配置php7.2中的yaf模块

没装之前

# /usr/local/php7.2/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

[Zend Modules]

我们可以看到,里面没有yaf模块,也没有redis模块。

下面我们开始安装yaf模块。

  • 下载yaf
sudo wget https://github.com/laruence/yaf/archive/yaf-3.0.9.tar.gz
  • 解压
sudo tar -zvxf yaf-3.0.9.tar.gz
  • 进入,并phpize处理
cd yaf-yaf-3.0.9 && /usr/local/php7.2/bin/phpize
  • 编译
./configure --with-php-config=/usr/local/php7.2/bin/php-config
  • 安装
make && make install
  • 测试一波
make test
  • 开启一些函数 shell_exec,proc_get_status,proc_open
vim /usr/local/php7.2/etc/php.ini
  • 增加ini配置
extension = "yaf.so"
  • 重启lnmp
# lnmp restart
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx...  done
Shutting down MySQL.. SUCCESS! 
Gracefully shutting down php-fpm . done
Gracefully shutting down php-fpm . done
Starting LNMP...
Starting nginx...  done
Starting MySQL. SUCCESS! 
Starting php-fpm  done
Starting php-fpm  done

此时查看模块

#/usr/local/php7.2/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaf
zlib

[Zend Modules]

我们发现,多了一个yaf

第三步配置php7.2中的redis模块

redis是必须的,很多项目都需要用到

./addons.sh install redis

就这么简单!

#  /usr/local/php7.2/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaf
zlib

[Zend Modules]

尝试运行项目

创建enable-php7.2-pathinfo.conf

cp enable-php-pathinfo.conf enable-php7.2-pathinfo.conf

修改内容为

location ~ [^/]\.php(/|$)
        {
            fastcgi_pass  unix:/tmp/php-cgi7.2.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            include pathinfo.conf;
}

配置nginx

server
    {
        listen 80;
        #listen [::]:80;
        server_name official.caomall.cn;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/official/tiger/public;

        #error_page   404   /404.html;


        include enable-php7.2-pathinfo.conf;

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

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

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

	location / {
    		if (!-e $request_filename) {
        		rewrite ^(.*)$ /index.php?s=$1 last;
        		break;
    		}
	}

        access_log  /home/wwwlogs/access.official.log;
}




重启lnmp

没毛病。环境搭建ok!

posted @ 2019-12-30 15:55  TBHacker  阅读(236)  评论(0编辑  收藏  举报