PHP’s Zend Opcache Config & Web Viewer

PHP 5.5. has zend opcache support in core. Since APC is not updated from long time, we made a switch to new Zend Opcache. Below is our config and web-based stats viewer.

PHP’s Zend Opcache Config

In your php.ini or /etc/php5/fpm/conf.d/05-opcache.ini 
zend_extension=opcache.so
opcache.memory_consumption=512
opcache.max_accelerated_files=50000

;following can be commented for production server
opcache.revalidate_freq=0
opcache.consistency_checks=1

OCFS2 cluster – quick setup guide



OCFS2 is a POSIX-compliant shared-disk cluster file system for Linux capable of providing both high performance and high availability. Cluster-aware applications can make use of parallel I/O for higher performance. OCFS2 is mostly used to host Oracle Real application clusters (RAC) database on Linux clusters.

The below steps shows how to create ocfs2 filesystem on top a multipath’d SAN lun and mount it on Linux clusters.

1. Identify the nodes that will be part of your cluster.

2. Export/Zone the LUNs on the SAN end and check whether they are accessible on all the hosts of the cluster. (fdisk -l or multipath -ll)

3. If you need multipathing, configure multipath and the multipathing policy based on your requirement. For Linux multipath setup, refer Redhat’s multipath guide.

4. Create OCFS2 configuration file (/etc/ocfs2/cluster.conf) on all the cluster nodes.

How to Take Ownership of a File, Folder Using Command-line in Window 7 and Vista

Taking ownership of a file

Click Start, click All Programs, click Accessories, right-clickCommand Prompt, and then click Run as Administrator.
Type the following command and press ENTER:  TAKEOWN /F<filename>
(Replace the text <filename> with the full path of the actual file.)
If the operation was successful, you should see the following message:
“SUCCESS: The file (or folder): “filename” now owned by user “Computer Name\User name“.”
Then to assign the Administrators group Full Control Permissions for the file, you may use the ICACLS command.
Use this syntax:  ICACLS <filename> /grant administrators:F

Cài đặt thêm extension openssl vào PHP

Tải bản PHP tương ứng với bản đang chạy về server, giải nén
cd {php_dir (vừa giải nén)}/ext/openssl 
Chạy phpize (lưu ý phải chạy đúng với phiên bản php đang chạy trong trường hợp cài nhiều bản php trên server) Ví dụ:  sudo /u01/app/httpd2/php/bin/phpize
./configure –with-php-config=/u01/app/httpd2/php/bin/php-config
make
make install
Lưu ý: 
- Có thể file {php_dir (vừa giải nén)}/ext/openssl/config.m4  không tồn tại hoặc bị sai tên –> tìm file khác hoặc đổi lại tên là được.


Custom symfony error pages for 404 and 500 errors

500 error page
- Since symfony 1.2 your error page must be stored as error.html.php in the folder /config/errors/
- Default file:/lib/vendor/symfony/lib/exception/data/error.html.php
Available variables:  (một số biến được dùng trong file error)
- $exception: The exception.
- $code: The status code. Defaults to 500 but might have been replaced by $response->getStatusCode().
- $text: The status text. Defaults to “Internal server error” but might have been replaced by $response->getStatusText().
- $format: The request format. Defaults to “html” but might have been replaced by $response->getRequestFormat().

symfony execute raw query with doctrine

$query = ‘INSERT INTO table_name (`field1`, `field2 `, `content`, `created_at`) values ‘ ….

$conn = Doctrine_Manager::connection();
$pdo = $conn->execute($query);

Enable logging in the Symfony production environment

To enable symfony logging edit the file apps/frontend/config/settings.yml
prod:
  .settings:
    logging_enabled:        on
edit apps/frontend/config/factories.yml
prod:
  logger:
    class: sfAggregateLogger
    param:
      level: debug