PHP代码发布-基于软链
2018-03-03 00:00
218 查看
摘要: 如果用的发布系统是基于软链更新代码的,比如发布新版本由 /data/release/version1 切换到 /data/release/version2。
那么nginx好像有缓存,永远不会生效新的代码。
https://www.jianshu.com/p/652789985230
把 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
改成 fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
这个软链就可以自动更新了,index.php 拿到的 DIR 是最新的。
作者:龙权
链接:https://www.jianshu.com/p/652789985230
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/
The minimum configuration to get your application running under Nginx is:
Secure Symfony 3.x, 2.x
Depending on your PHP-FPM config, the fastcgi_pass can also be fastcgi_pass 127.0.0.1:9000.
This executes only app.php, app_dev.php and config.php in the web directory. All other files ending in ".php" will be denied.
If you have other PHP files in your web directory that need to be executed, be sure to include them in the location block above.
After you deploy to production, make sure that you cannot access the app_dev.php or config.php scripts (i.e. http://example.com/app_dev.php and http://example.com/config.php). If you can access these, be sure to remove the DEV section from the above configuration.
那么nginx好像有缓存,永远不会生效新的代码。
使用软链接实现
nginx 新版本 软链 变化https://www.jianshu.com/p/652789985230
把 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
改成 fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
这个软链就可以自动更新了,index.php 拿到的 DIR 是最新的。
作者:龙权
链接:https://www.jianshu.com/p/652789985230
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
相关资料
nginx wikihttps://www.nginx.com/resources/wiki/start/topics/recipes/symfony/
The minimum configuration to get your application running under Nginx is:
Secure Symfony 3.x, 2.x
server { server_name domain.tld www.domain.tld; root /var/www/project/web; location / { # try to serve file directly, fallback to app.php try_files $uri /app.php$is_args$args; } # DEV # This rule should only be placed on your development environment # In production, don't include this and don't deploy app_dev.php or config.php location ~ ^/(app_dev|config)\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; } # PROD location ~ ^/app\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; # Prevents URIs that include the front controller. This will 404: # http://domain.tld/app.php/some-path # Remove the internal directive to allow URIs like this internal; } # return 404 for all other php files not matching the front controller # this prevents access to other php files you don't want to be accessible. location ~ \.php$ { return 404; } error_log /var/log/nginx/project_error.log; a 7fe0 ccess_log /var/log/nginx/project_access.log; }
Depending on your PHP-FPM config, the fastcgi_pass can also be fastcgi_pass 127.0.0.1:9000.
This executes only app.php, app_dev.php and config.php in the web directory. All other files ending in ".php" will be denied.
If you have other PHP files in your web directory that need to be executed, be sure to include them in the location block above.
After you deploy to production, make sure that you cannot access the app_dev.php or config.php scripts (i.e. http://example.com/app_dev.php and http://example.com/config.php). If you can access these, be sure to remove the DEV section from the above configuration.
相关文章推荐
- Spring基于事件驱动模型的订阅发布模式代码实例详解
- 360发布通用php防护代码
- 基于聚合数据的移动联通基站API接口的php完整代码实例
- 让php处理图片变得简单 基于gb库的图片处理类附实例代码下载
- 经典代码(一):基于PHP的webservice的使用
- wemall app商城源码中基于PHP的ThinkPHP惯例配置文件代码
- 分享一个分布式消息总线,基于.NET Socket Tcp的发布-订阅框架,附代码下载 推荐
- 基于php的基金财务数据接口调用代码实例
- 基于PHP+jQuery+MySql实现红蓝(顶踩)投票代码
- 基于递归实现的php树形菜单代码
- 基于新浪sae使用php生成图片发布图文微博
- 基于python实现jenkins自动发布代码平台 推荐
- 用PHP写的基于Memcache的Queue实现代码
- Spring基于事件驱动模型的订阅发布模式代码实例详解
- 基于PHP+jQuery+MySql实现红蓝(顶踩)投票代码
- 基于Snoopy的PHP近似完美获取网站编码的代码
- PHP基于Redis消息队列实现发布微博的方法
- 开源内容管理系统Joomla正式发布3.5版本 基于PHP 7
- 基于mysql , php 的代码自动生成
- 基于PHP代码实现中奖概率算法可用于刮刮卡、大转盘等抽奖算法