2021年3月

centos8 安装php8

1.下载软件
   

 wget http://www.ijg.org/files/jpegsrc.v9d.tar.gz
 wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.gz?download
 wget http://mirrors.nju.edu.cn/gnu/libiconv/libiconv-1.16.tar.gz

2.安装 扩展库
    2.1 
    

 tar zxvf jpegsrc.v9d.tar.gz 
 cd jpeg-9d/
 ./configure --prefix=/usr/local/lib/jpeg --enable-shared --enable-static
 make
 make install
 cd ../

     2.2
    

 tar zxvf libpng-1.6.37.tar.gz 
 cd libpng-1.6.37
 ./configure --prefix=/usr/local/lib/libpng
 make
 make install
 cd ../

     2.1
     tar zxvf libiconv-1.16.tar.gz
     cd libiconv-1.16/
     ./configure --prefix=/usr/local/lib/libiconv
     make
     make install
     cd ../

     vi /etc/ld.so.conf.d/my.conf

    添加yihang:
    /usr/local/lib
    /usr/local/lib/lib
    

    然后:
    ldconfig

    tar zxvf libxml2-2.9.10.tar.gz
    cd libxml2-2.9.10/
    ./configure
    make
    make install
    cd ../

    yum install gcc gcc-c++ autoconf zlib zlib-devel glibc glibc-devel libpng libpng-devel libjpeg-turbo libjpeg-turbo-devel freetype freetype-devel xz gd libmcrypt mhash libxml2 libxml2-devel glib2 glib2-devel bzip2 bzip2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel  libidn  openssl openssl-devel 
    yum install sqlite-devel libcurl-devel oniguruma libzip libzip-devel

    tar xvzf sqlite-autoconf-3071502.tar.gz
    cd sqlite-autoconf-3071502
    ./configure --prefix=/usr/local
    make
    make install

    https://github.com/kkos/oniguruma

    ./configure
    ./configure --prefix=/usr --libdir=/lib64
    make
    sudo make install


3.安装php
    cd php-8.0.3
    export LIBS="-lm -lresolv"
    export DYLD_LIBRARY_PATH="/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64:/usr/libexec/"n
    export LD_LIBRARY_PATH="/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64:/usr/libexec/"
    ./configure \
    --prefix=/usr/local/service/php8.0.3 \
    --with-config-file-path=/usr/local/service/php8.0.3/etc \
    --with-mysqli=shared,mysqlnd \
    --with-pdo-mysql=shared,mysqlnd \
    --enable-opcache \
    --with-iconv=/usr/local/lib/libiconv \
    --with-freetype \
    --with-jpeg \
    --with-libxml \
    --enable-xml \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-inline-optimization \
    --with-curl \
    --enable-mbregex \
    --enable-fpm \
    --enable-mbstring  \
    --with-openssl \
    --with-mhash \
    --enable-pcntl \
    --enable-sockets \
    --enable-gd \
    --with-zip \
    --enable-soap \
    --with-fpm-user=www \
    --with-fpm-group=www \
    --with-mysql-sock=/data/mysql/mysql.sock \


    --disable-rpath \ (使用后,不会搜索附加的动态链接库,会造成opcache编译不过)
    --with-xmlrpc \ XML-RPC是Userland Software公司设计的一种格式:是一种使用HTTP协议传输XML格式文件来获取远程程序调用(Remote Procedure Call)的传输方式。官方网站是www.xmlrpc.com。
    --enable-maintainer-zts \  pthreads多线程扩展需要开启zts

    
    make 
    make install

    echo -e '\nexport PATH=/usr/local/service/php8.0.3/bin:/usr/local/service/php8.0.3/sbin:$PATH\n' >> /etc/profile && source /etc/profile

4.配置文件

5. 安装扩展
ImageMagick是一套功能强大、稳定而且免费的工具集和开发包,可以用来读、写和处理超过89种基本格式的图片文件

        yum -y install perl-CPAN ImageMagick

        tar zxvf ImageMagick-7.0.7-28.tar.gz
        cd ImageMagick-7.0.7-28
        ./configure
        make
        make install
        cd ../

        tar zxvf imagick-3.4.3.tgz
        cd imagick-3.4.3
        /usr/local/service/php8.0.3/bin/phpize
        ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config
        make
        make install
        cd ../

    5.2 redis

    wget https://download.redis.io/releases/redis-6.2.1.tar.gz
    make
    make PREFIX=/usr/local/service/redis install
    cd ../

    mkdir -p /data/redis/6379/
    配置文件:redis.conf
    启动:
    /usr/local/service/redis/bin/redis-server /data/redis/6379/redis.conf & 2&1 > /data/redis/6379/redis.log


    redis.so

    https://github.com/phpredis/phpredis/archive/5.3.3.tar.gz

    tar zxvf 5.3.3.tar.gz 
    cd  phpredis-5.3.3/
    /usr/local/service/php8.0.3/bin/phpize
    ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config
    make
    make install
    cd ..


    swoole

    wget https://github.com/swoole/swoole-src/archive/v4.6.3.tar.gz
    tar zxvf v4.6.3.tar.gz
    cd swoole-src-4.6.3
    /usr/local/service/php8.0.3/bin/phpize
    ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config --enable-swoole-json
    make
    make install
    cd ..

 

掩码控制权限

<< : 左移运算符,num << 1,相当于num乘以2

: 右移运算符,num >> 1,相当于num除以2

: 无符号右移,忽略符号位,空位都以0补齐

异或(^ ): 一句话,相异为真 返回 boolean

与(&): 只有两位都为 1 则为真 ,0001 & 0101 也就是 0001

或(|): 只要两位有一位 为真则为真, 0001 | 0100,也就是0101

非(~): 对自身取反。

增 1<<0 2的0次方 0001
删 1<<1 2的1次方 0010
改 1<<2 2的2次方 0100
查 1<<3 2的3次方 1000

添加权限时: current | permissions
删除权限时: current &= ~permissions
验证是否有权限时 (current & permissions)>0

1.composer create-project composer/satis
2.vi satis.json
{

    "name": "composer/jetsong",
    "homepage": "http://satis.jetsong.top",
    "repositories": [{
            "type": "vcs",
            "url": "http://gitlab.sdjian.com:31001/php-base-server/facade/comment-like-base.git"
    }],
    "require": {
            "facade/comment-like-base": "*"
    },
    "require-dependencies": true,
    "archive": {
            "directory": "dist",
            "format": "tar",
            "prefix-url": "http://satis.jetsong.top",
            "skip-dev": true
    },
    "config": {
            "secure-http": false
    }

}
3.php bin/satis build satis.json public/
4.开启服务
server {

listen       31005;
server_name  127.0.0.1;

access_log  /data/logs/nginx/satis.access.log  main;
error_log /data/logs/nginx/satis.error.log;
root   /data/composer/satis/public;

location / {
    index  index.html index.php;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}

location ~ \.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi.conf;
}

}
5.使用仓库
{

"repositories":[
    {
        "type":"composer",

"url": "http://satis.jetsong.top"

    }
],

"require": {

    "facade/comment-like-base": "*"
},
"config":{
    "secure-http": false
}

}

How do I install untrusted packages safely? Is it safe to run Composer as superuser or root?#

Certain Composer commands, including exec, install, and update allow third party code to execute on your system. This is from its "plugins" and "scripts" features. Plugins and scripts have full access to the user account which runs Composer. For this reason, it is strongly advised to avoid running Composer as super-user/root.

You can disable plugins and scripts during package installation or updates with the following syntax so only Composer's code, and no third party code, will execute:

composer install --no-plugins --no-scripts ...
composer update --no-plugins --no-scripts ...
The exec command will always run third party code as the user which runs composer.

In some cases, like in CI systems or such where you want to install untrusted dependencies, the safest way to do it is to run the above command.

反射是指在PHP运行状态中,扩展分析PHP程序,导出或者提取出关于类、属性、方法、参数等的详细信息,包括注释。这种动态获取信息以及动态调用对象方法的功能,被称为反射API。

//获取对象的属性列表
$reflect = new ReflectionObject($stu);
$props = $reflect->getProperties();
foreach ($props as $key_p => $value_p) {

var_dump($value_p->getName());

}
//获取对象的方法列表
$method = $reflect->getMethods();
foreach ($method as $key_m => $value_m) {

var_dump($value_m->getName());

}
1、反射可以用于文档、文件生成。可以用它对文件里的类进行扫描,逐个生成描述文档;
2、既然反射可以探知类的内部结构,那么可以用它做hook实现插件功能;
3、可以用于做动态代理,在未知或者不确定类名的情况下,动态生成和实例化一些类和执行方法;
4、对于多次继承的类,我们可以通过多次反射探索到基类的结构,或者采用递归的形式反射,实现实例化所有继承类,这即是PHP依赖注入的原理。

优点
1、支持反射的语言提供了一些在低级语言中难以实现的运行时特性。
2、可以在一定程度上避免硬编码,提供灵活性和通用性,解耦。
3、可以作为一个第一类对象发现并修改源代码的结构(如代码块、类、方法、协议等)。
4、可以在运行时像对待源代码语句一样计算符号语法的字符串(类似JavaScript的eval()函数),进而可将跟class或function匹配的字符串转换成class或function的调用或引用。
5、可以创建一个新的语言字节码解释器来给编程结构一个新的意义或用途。
劣势
1、此技术的学习成本高。面向反射的编程需要较多的高级知识,包括框架、关系映射和对象交互,以利用更通用的代码执行。
2、同样因为反射的概念和语法都比较抽象,过多地滥用反射技术会使得代码难以被其他人读懂,不利于合作与交流。
3、由于将部分信息检查工作从编译期推迟到了运行期,此举在提高了代码灵活性的同时,牺牲了一点点运行效率。
4、通过深入学习反射的特性和技巧,它的劣势可以尽量避免,但这需要许多时间和经验的积累。