PHP 不会死 —— 我们如何使用 Golang 来阻止 PHP 走向衰亡
https://zhuanlan.zhihu.com/p/256246753
GO+PHP, 让全宇宙最好的两种语言合体的神器——RoadRunner
https://zhuanlan.zhihu.com/p/60599237
简单的介绍(蹩脚的机翻)
享受PHP与Go的强大合体【RoadRunner】的乐趣!官方介绍的翻译
关于RST SOAP RPC的简单对比
PHP 不会死 —— 我们如何使用 Golang 来阻止 PHP 走向衰亡
https://zhuanlan.zhihu.com/p/256246753
GO+PHP, 让全宇宙最好的两种语言合体的神器——RoadRunner
https://zhuanlan.zhihu.com/p/60599237
简单的介绍(蹩脚的机翻)
享受PHP与Go的强大合体【RoadRunner】的乐趣!官方介绍的翻译
关于RST SOAP RPC的简单对比
I have to install it manually.
First: Login into your php container as root, then install via pecl.
docker exec -it -u 0 php /bin/sh pecl install ast-1.0.1
After that, you need to enable it in php.ini like:
extension=ast.so
restart php-fpm in docker with
kill -USR2 1
This solves my problem and may help. (edited)
容器之间的通讯有几种。
1 通过端口。
比如,php fpm容器通过暴露9000端口,nginx利用该端口,把php交给fpm容器
再复杂一点,还可以通过配置虚拟网络的。让不同的服务运行在不同的ip的端口上。
2. 通过link
更简单的方法是通过link。当一个容器需要另外一个容器的是时候,只要在docker-compse.yml文件里写上link 服务名service : 别名alias 即可。在该容器内,这个 service(或者别名)就是指向另外的容器的。
例子
比如有2个容器,php容器和db容器。php容器需要访问db,发现通过127.0.0.1这样的并不可以。因为,db是运行在另外一个容器内的,127.0.0.1则是本php容器。而非db容器- 通过expose暴露的端口也仅仅是暴露给宿主,而不是其他容器。这样只要在php容器的配置加上link:
php:
....
links:
- "mysql"
mysql:
....
然后在 php 的配置里,链接数据库只要写 mysql 即可
DATABASE_URL="mysqli://user:user@mysql:3306/user-db?serverVersion=5.7"
进入php容器查看ping mysql,会发现docker已经把mysql这个写入了类似hosts文件的地方。具体哪我也不知道。
我正在看5.2的教程,昨天升级到5.3后,发现教程和实际情况对不上了。再看了官网,发现它了修改。
链接
1. https://symfony.com/blog/new-in-symfony-5-3-guard-component-deprecation
2. https://symfony.com/doc/current/security/authenticator_manager.html
昨天升级Symfony 从5.2升到5.3. 自己弄了很久,后来发现其实官方有升级指引的。
小升级 https://symfony.com/doc/current/setup/upgrade_minor.html
大升级 https://symfony.com/doc/current/setup/upgrade_major.html
主要备份好自己的路由,模板啥的。其实有git也不用担心啥。
AuthLog属于securtiy模块,配置文件是security.yaml文件。配置中主要的key是 firewall.
负责Form登陆鉴定的类主要是LoginFormAuthenticator , 实现了 AuthenticatorInterface .
关于几个概念, 可以参考这篇文章
备注: 完成文章后发现Symfony 5.3对Auth做了改动。所以请注意版本。
brew tap elastic/tap
brew install elastic/tap/elasticsearch-full
From:
https://www.elastic.co/guide/en/elasticsearch/reference/current/brew.html
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep elasticsearch
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
launchctl remove homebrew.mxcl.elasticsearch
pkill -f elasticsearch
rm -f ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
brew uninstall elasticsearch
# double check existence
ls -al /usr/local/bin/elasticsearch*
ls -al ~/Library/LaunchAgents
From:
长久以来,我们一直使用Apache作为Web服务器,用Apache2.0 Handler 方式来运行PHP, 也就是mod_php, 把PHP中作为Apache的一个module的来运行。当时算是比较快的配置方式。不过这都是10多年前的配置了。
现在常用的搭配是nginx + PHP-FPM. 这种配置在目前docker时代显得比较合适。web server选用nginx 运行在一个容器内. php 作为一个单独的容器运行,通常打开9000端口来和nginx通讯。
选择 php:fpm-alpine 的镜像。记得最后要expose 9000端口。
/etc/nginx/cond.d/default.conf
upstream php-upstream {
server php:9000
}
这样配置,通过phpfinfo查看, Server API就是 FPM/FastCGI 了。
# newest PHP version FROM php:fpm-alpine # Add git RUN apk --update --no-cache add git # PostgreSQL RUN set -ex && apk --no-cache add postgresql-dev RUN docker-php-ext-install pdo_mysql COPY --from=composer /usr/bin/composer /usr/bin/composer RUN rm -rf /var/cache/apk/* && rm -rf /tmp/* WORKDIR /var/www CMD composer -V; php-fpm EXPOSE 9000
注意,需要手动的启动 php-fpm
附录2:nginx的Dockerfile:
FROM nginx:alpine WORKDIR /var/www ADD nginx.conf /etc/nginx ADD sites /etc/nginx/sites-available ADD conf.d /etc/nginx/conf.d CMD ["nginx"] EXPOSE 80 443
附录3: Docker-compose.yml
version: '3' services: php: build: ./docker/php image: base-php:latest volumes: - ./app:/var/www:cached nginx: build: ./docker/nginx image: base-nginx:latest volumes: - ./app:/var/www:cached - ./logs/nginx:/var/log/nginx:cached ports: [80:80, 443:443]
昨天发现一个问题。添加了一个用php发出http auth的脚本,在本地是测试正常,上线后却反复弹出auth窗口,似乎无法通过验证。
分析后发现,本地php是用moudle方式运行的。在live是CGI/FastCGI 。 查阅后得知,由于收到CGI协议的限制,无法使用类似 PHP_AUTH_*这样的超级变量。
解决办法是通过 Apache 的rewrite功能,手动地把http auth 请求加入到环境变量中。
.htaccess 大致如下
#
# For CGI/FastCGI , attach Authroziation header in Env Variabels.
#
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
这样,在php内就可以通过$_SERVER[‘HTTP_AUTHORZATION’] 来获取http 的 Authorization的头部信息了。然偶通过字符串和base64解码就能获得用户输入的密码了。