Category Archives: apc

how to remove cache from admin panel using .htaccess

i have a single .htaccess file for both admin panel and website. In my website I am using apc cache for cache and it works fine in website, but in backend/admin panel there are lots of issues due to cache.

now i don't need a cache in admin panal but website i need a cache

So, please tell me how I can write a regex in .htaccess for both website as well as admin panel.

Currently I am using this code in my .htaccess

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/svg+xml "access 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

For example :

cache works on : www.xyz.com/
cache not works on : www.xyz.com/admin

APC for multiple websites

I'am using APC for caching. I have two website on my server, and I want to use APC seperate for these sites.

So one.site.com has it's own cache And tow.site.com has it's own cache too

Is it possible with APC?

With default config, when I go to two.site.com I see the same data as on one.site.com

I use PHP, Apache, Kohana

php-apcu (CGI/FastCGI) apc_fetch always return false

When using the php-apcu (https://github.com/krakjoe/apcu) extension (not apc) in a php CGI environment the stored data fromapc_store are empty.

Anyone has experiences on how to solve this issue?

Example PHP File: test-apc.php

<?php
$k = 'test';
if(isset($_GET['get'])) {
    $result = apc_fetch($k);
    echo "Read entry '$k': $result";
} else if(isset($_GET['clear'])) {
    echo "Clear entry '$k'";
    apc_clear_cache('user');
} else {
    apc_store($k, "HelloWord");
    echo "Write entry '$k' set";
}
print_r(apc_cache_info('user'));
?>

Steps to reproduce:

  1. Open http://server/test-apc.php to call apc_store
  2. Open http://server/test-apc.php?get to receive stored data using apc_fetch

BTW: apc_cache_info('user') shows it properly with first request, second is empty

Relevant packages (OS: Debian 3.2.63):

  • Apache 2.2.22 (mpm-prefork, suexec-custom, wrapper)
  • php5.5 as CGI
  • php5-apcu 4.0.7
  • (and dependencies)

xampp apache apc not working in symfony2

I have prollem of high TTFB (time to first byte). I have to install APC or xcache, both of which are not getting started on my apache webserver.

Please advise how to install the APC or xcache. opcache is installed, but I do not know how to use in Symfony2.

[email protected] /c/xampp/htdocs/ims
$ php -v
C:\xampp\php\ext\php_apc.dll doesn't appear to be a valid Zend extension
PHP 5.6.11 (cli) (built: Jul  9 2015 20:55:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


In the php.ini I have,
[APC]
zend_extension = "C:\xampp\php\ext\php_apc.dll"
;specifies the size for each shared memory segment 8MB to start
apc.shm_size=8M
;max amount of memory a script can occupy
apc.max_file_size=1M
apc.ttl=0
apc.gc_ttl=3600
; means we are always atomically editing the files
apc.file_update_protection=0
apc.enabled=1
apc.enable_cli=1
apc.cache_by_default=1
apc.include_once_override=0
apc.localcache=0
apc.localcache.size=512
apc.num_files_hint=1000
apc.report_autofilter=0
apc.rfc1867=1
apc.slam_defense=0
apc.stat=1
apc.stat_ctime=0
apc.ttl=7200
apc.user_entries_hint=4096
apc.user_ttl=7200
apc.write_lock=1

In my app/config/config_prod.yml

I want to do both framework:

framework:
    validation:
        cache: validator.mapping.cache.apc
    serializer:
        cache: serializer.mapping.cache.apc

#doctrine:
#    orm:
#        metadata_cache_driver: apc
#        result_cache_driver: apc
#        query_cache_driver: apc

I have commented doctrine for now. Will deal with it later.

In, app.php: I want to do the following

$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);

hard links between php files in different directories, what should be the expected behaviour of __FILE__

I have two websites that are identical in structure. The index.php file needs to generate different content depending on the domain that the page is being served from. I am using apache 2.2 and created two virtual hosts using two different folders under /var/www (/var/www/site.domain.com and /var/www/site.domain.ca)

I am using FILE to obtain the full path of the executing index.php and depending on the path I output the correct content.

Since the files are all the same, I wanted to use links to make editing the file easier, so instead of editing one of the index.php, then copying it to the other directory, I wanted editing either of files to update the other.

I used the cp -al command to copy with hard links:

cp -al /var/www/site.domain.com /var/www/site.domain.ca

The problem is that when I access the index.php file in one site vs. the other, the FILE variable does not reflect the path of which index.php file is executing. Depending on which domain I visit first, the FILE will reflect the path of that domain.

I will try using getcwd to see if that works, but can someone explain why this is happening. Shouldn't FILE reflect the current script that's executing.

These are hard links, not soft links.

Is apache caching the script, is APC the source of the problem?

Update: getcwd() worked, it seems to always return the correct current directory.

APC OpCode not working with PHP-FPM

I'm trying to get APC OpCode Cache working along with:

PHP 5.4.30, APC 3.1.15-dev, and PHP-FPM PHP 5.4.30 (fpm-fcgi)

However my "System Cache Entries" on my apc_stats.php is ALWAYS EMPTY

I have the following configuration:

* On /etc/httpd/conf.d/fastcgi.conf

User apache
Group apache
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiWrapper Off

<IfModule mod_fastcgi.c>
        DirectoryIndex index.html index.shtml index.cgi index.php

        AddHandler php5-fcgi .php
        Action php5-fcgi /php5-fcgi
        Alias /php5-fcgi /php-fpm/php5-fcgi
        FastCgiExternalServer /php-fpm/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 3600

</IfModule>

* On /etc/php-fpm.d/www.conf

[www]
listen = 127.0.0.1:9000
pm = dynamic
pm.start_servers = 10

* On /etc/php.d/apc.ini

apc.enabled=1
apc.shm_size=512M
apc.mmap_file_mask=/apc.shm.XXXXXX

Please Help! I have tried everything I have think of... =(

.htaccess :: Cannot set a upload_tmp_dir

Looks like a very simple task but it's not working... I'm trying to set upload_tmp_dir to the ROOT directory on my .htaccess file...

php_value upload_tmp_dir /

I'm printing out the results and it's stays the same as the default on my php.ini

echo 'Your Temp Upload Directory : '.ini_get('upload_tmp_dir').'<br>';

IOW... not working.

I know that it's impossible to set it via :

ini_set('upload_tmp_dir','/');

What am I doing wrong here ?