Disable or remove apc
Asked Answered
C

5

5

I installed APC on my ubuntu 11.04 linux and I want to make some performance benchmarks to see what's the speed improvement over PHP without APC but I don't know how to disable/remove the APC.

I tried to empty my apc.ini files but it didn't worked. Still after I load a page for the first time, the page will be stored in the cached and the second time I load the page, it loads much faster.

Here's a PHP file that I use to measure the time.

<?php 
    function getTime() 
        { 
        $a = explode (' ',microtime()); 
        return(double) $a[0] + $a[1]; 
        } 
    $Start = getTime(); 
    ?>
    <?php require_once("includes/connection.php");?>
    <?php require_once("includes/functions.php");?>
    <?php
        find_selected_page(true);   
    ?>
    <?php require_once("includes/header.php");?>

        <table id="structure">
            <tr>
                <td id="navigation">
                    <?php echo navigation_public($sel_subject,true);
                      //            $sel_page is sent as a GLOBAL   so that we can reuse is in the page area
                    ?>
                </td>
                <td id="page">
                    <?php

                        if($sel_page!=NULL)
                        {
                            echo "<h2>".htmlentities($sel_page['menu_name'])."</h2>";
                            echo "<p>".strip_tags(nl2br($sel_page['content']),"<b><br><p><a>")."</p>";
                        }
                        else if($sel_subject!=NULL) 
                        {
                            echo "<h2>".$sel_subject['menu_name']."</h2>";
                        }
                        else 
                        {
                            echo "<h2>Welcome to Widget Corp</h2>";
                        }
                    ?>
                </td>   
            </tr>   
        </table>    
        <?php 
    $End = getTime(); 
    echo "Time taken = ".number_format(($End - $Start),3)." secs"; 
    ?>
    <?php require("includes/footer.php");?>
Caesura answered 3/7, 2012 at 11:30 Comment(2)
Removing the apc.ini file should be enough, have you restarted Apache after you cleared that file?Institutive
I removed it's content. Not the file itself. And yes I restarted my apache using the sudo /etc/init.d/apache2 restart .Caesura
E
11

Change :

extension=apc.so

By :

;extension=apc.so

In :

/etc/php5/apache2/conf.d/apc.ini

And restart Apache server :

apache2ctl graceful
Engrail answered 3/7, 2012 at 11:46 Comment(3)
Sorry but it seems that the speed of my pages still improves. When I load apc.php in the browser it tells me "No cache info available. APC does not appear to be running." but when I load a page for the first time it takes 0.059 seconds and the second and third time and so on it takes about 0.010 seconds.Caesura
Your methodology for measuring the performance of pages is wrong. You are measuring the time PHP takes to run the script - but opcode caches speed up the time taken to parse the script - the resulting data structure is the same and processed in the same way. If you want to measure the performance difference, then look at %D in apache log - or use firebug etc.Elias
@DragosC. you must have another cache activated that's making this performance impovement. (most likely the cache by default in whatever system you are writing your web application).Astrionics
R
7

You can enter the following command with root permission:

pecl uninstall apc
Regolith answered 19/9, 2013 at 14:8 Comment(0)
M
6

apc.enabled can be set to 0 to disable APC from php.ini Than restart your web server or php-fpm.

Marismarisa answered 3/7, 2012 at 12:56 Comment(0)
B
0

you can use following script then put it on 1st line of your php file,

apc_clear_cache();
Bissau answered 22/3, 2016 at 14:23 Comment(0)
D
0

If you are running apache:

  1. edit or create an .htaccess file in the root of your project

  2. add this line to the file

    php_flag apc.cache_by_default Off

  3. restart the server

Determination answered 17/2, 2021 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.