Table of Contents
回复内容:
注意事项
Home Backend Development PHP Tutorial osx下vagrant centos6 lnmp环境下,为什么PHP也有类似缓存的情况?

osx下vagrant centos6 lnmp环境下,为什么PHP也有类似缓存的情况?

Jun 06, 2016 pm 08:29 PM
php vagrant

如题,设置了Vagrant文件同步,我在OSX上修改文件以后,马上去vagrant centos环境下去查看文件内容,已经是更新以后的内容,发现网上所说的同步慢貌似不存在,但是我用浏览器 http访问这个PHP文件的时候还是老版本的,大概需要10秒左右才能刷新出最新的(没有在centos6中做任何类似重启等操作)

请问有人碰到过么?

另外说明下PHP文件很简单,就是一个echo打印语句做测试,无任何逻辑

回复内容:

如题,设置了Vagrant文件同步,我在OSX上修改文件以后,马上去vagrant centos环境下去查看文件内容,已经是更新以后的内容,发现网上所说的同步慢貌似不存在,但是我用浏览器 http访问这个PHP文件的时候还是老版本的,大概需要10秒左右才能刷新出最新的(没有在centos6中做任何类似重启等操作)

请问有人碰到过么?

另外说明下PHP文件很简单,就是一个echo打印语句做测试,无任何逻辑

php 开字节码缓存了吧?

看看php 版本,新版默认开启opcache 了

修改 web 服务器配置文件,为静态文件

<code>  apache: 将 EnableSendfile on 改为 EnableSendfile off
   
  nginx: 将 sendfile on; 改为 sendfile off;</code>
Copy after login

php 开发时可以禁用,apc,opcode,xcache等。

注意事项

问题一)使用 Apache/Nginx 时会出现诸如图片修改后但页面刷新仍然是旧文件的情况,是由于静态文件缓存造成的。需要对虚拟机里的 Apache/Nginx 配置文件进行修改:

<code>#nginx配置
sendfile off
#apache 配置
EnableSendFile off 
</code>
Copy after login

问题二:启动多个虚拟机提示错误“2222 端口 in use”

解决办法:(参考文章:Vagrant SSH errors with multiple VMs: Port 2222 in use)

<code>config.vm.network "forwarded_port", guest: 22, host: 2220 ,id: 'ssh'
</code>
Copy after login

问题三:如果遇到 php 代码也感觉被缓存起来了,请关闭apc,opcode(从php5.5及以后版本默认开启opcode)

版权声明:本文为博主原创文章,原文永久地址:http://www.vincentguo.cn/default/26.html

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles