opcache与cgi / fastcgi

时间:2016-10-28 11:16:15

标签: php apache opcache

我试图在我的服务器上运行opcache,该服务器在apache2中托管一个网站。我正在运行debian 8。 然而,它似乎是在脚本中达到零。 我已经尝试将php模式改为cgi但这并没有改变任何东西。我还尝试使用以下命令禁用suPHP

a2endismod suPHP

再次,这并没有为这个问题做任何事情。 有没有人碰巧知道是什么原因造成的?

enter image description here

1 个答案:

答案 0 :(得分:0)

此问题已经得到解答here

引用:

  

这似乎是您使用的是cgi(FastCGI)而不是mod_php5。共享存储区(SMA)用于这两者,但仅保留后者的请求到请求。

但是,我应该添加以下启用内容:

...
<plugins>
    <plugin>
        <artifactId>maven-invoker-plugin</artifactId>
        <configuration>
            <pom>generator-pom.xml</pom>
            <showErrors>true</showErrors>
            <streamLogs>true</streamLogs>
        </configuration>
        <executions>
            <execution>
                <id>generate-sources</id>
                <phase>generate-resources</phase>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>add-source</goal>
                </goals>
                <configuration>
                    <sources>
                        <source>${project.build.directory}/generated-sources/mystuff</source>
                    </sources>
                </configuration>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven.compiler.plugin.version}</version>
    </plugin>

    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version> <!-- needed to run JUnit 5 tests -->
    </plugin>

    <plugin>
        <artifactId>maven-jar-plugin</artifactId>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>

使OPcache与我的设置兼容-Apache + php作为CGI / FastCGI(不是php-fpm)。显然,这种缓存机制是基于文件的,而不是SHM(请确保 opcache.file_cache=/var/tmp/php/opcache opcache.file_cache_only=1 可通过网络服务器访问,可能需要777权限。

启用上述功能后,您将不会在统计信息中看到任何缓存命中/未命中,因为-我们再次禁用了SHM缓存。

PS。很抱歉为您发布死角,只是在寻找类似问题的解决方案。