Locating apc.php File After Installing PHP-APC on Ubuntu 10.4 Server


1 views

When installing APC (Alternative PHP Cache) via apt-get install php-apc on Ubuntu 10.4 LTS, the administration script apc.php isn't automatically placed in your web directory. Here's how to find and deploy it properly:

The apc.php file typically comes with the APC source package. On Ubuntu/Debian systems, you have two main approaches:


# Method 1: Check the Apache directory
ls /usr/share/doc/php-apc/apc.php.gz

# Method 2: Extract from source
sudo apt-get source php-apc

After locating the file, follow these deployment steps:


# Uncompress if needed
sudo gzip -d /usr/share/doc/php-apc/apc.php.gz

# Copy to web directory
sudo cp /usr/share/doc/php-apc/apc.php /var/www/apc.php

# Set proper permissions
sudo chown www-data:www-data /var/www/apc.php
sudo chmod 644 /var/www/apc.php

For security, add these lines to your apc.php (around line 40):


defaults('ADMIN_USERNAME','your_admin_user');
defaults('ADMIN_PASSWORD','your_secure_password');

If the file isn't found in the package, download directly from PECL:


wget https://pecl.php.net/get/APC-3.1.13.tgz
tar -xzf APC-3.1.13.tgz
cp APC-3.1.13/apc.php /var/www/

After installing php-apc on Ubuntu 10.04 with apt-get install php-apc, the apc.php file is typically located in:

/usr/share/doc/php-apc/apc.php.gz

You'll need to extract it and move to your web directory:

gunzip /usr/share/doc/php-apc/apc.php.gz
sudo cp /usr/share/doc/php-apc/apc.php /var/www/

Before hunting for the file, confirm APC is properly installed:

php -i | grep apc

You should see output showing APC is enabled. If not, try restarting Apache:

sudo /etc/init.d/apache2 restart

Depending on your specific package version, apc.php might be in:

  • /usr/share/php-apc/apc.php
  • /usr/share/php5-apc/apc.php
  • /usr/share/doc/php-apc/examples/apc.php

If you can't locate the file, you can download it directly from PECL:

wget http://pecl.php.net/get/APC-3.1.9.tgz
tar -xzf APC-3.1.9.tgz
cp APC-3.1.9/apc.php /var/www/

After placing apc.php in your web directory, you might want to secure it:

sudo chmod 644 /var/www/apc.php
sudo chown www-data:www-data /var/www/apc.php

For added security, consider adding HTTP authentication via .htaccess:


AuthType Basic
AuthName "APC Admin"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

The default apc.php can be configured by modifying these variables at the top of the file:

define('USE_AUTHENTICATION', 1);
define('APC_USER','admin');
define('APC_PASS','password');
define('APC_UPLOAD_PROGRESS', 1);