Skip to main content

PHP

Configure PHP Securely

Make the following changes to /etc/php.ini:

# Do not expose PHP error messages to external users
display_errors = Off

# Enable safe mode
safe_mode = On

# Only allow access to executables in isolated directory
safe_mode_exec_dir = php-required-executables-path

# Limit external access to PHP environment
safe_mode_allowed_env_vars = PHP_

# Restrict PHP information leakage
expose_php = Off

# Log all errors
log_errors = On

# Do not register globals for input data
register_globals = Off

Install and Configure lighttpd + PHP on Gentoo

Posted in

Install lighttpd and php

  1. Read http://gentoo-wiki.com/HOWTO_Lighttpd and decide which USE flags you will need. Write those flags into /etc/portage/package.use. Since I plan to use fastcgi and php, I do have at least these two flags set.
  2. Check php installation. If php was installed but cgi USE flag was off, you have to reinstall php with "USE=cgi".
  3. Now install lighttpd:
    # emerge -v lighttpd
  4. Among the few opcode cache for php, xcache is quite stable on lighttpd. So install that:

Tune APC to Improve PHP Performance

Posted in

Adjust the parameters

Having installed APC for PHP does not automatically improve the performance. You have to adjust the parameters. At the very least, change these values:

apc.ttl="7200"
apc.user_ttl="7200"
apc.shm_segments="3"
apc.shm_size="90"

Setting apc.ttl and apc.user_ttl to none-zero can ensure that the cached php code gets refreshed at the given number of seconds without filling up the memory with stale entries.

Syndicate content