Cài đặt ECG Magento Code Sniffer kiểm tra magento coding standard

Before starting using our coding standard install PHP_CodeSniffer

  • sudo pear install PHP_CodeSniffer

Clone or download Magento PHP_CodeSniffer Coding Standard on your computer or install it with Composer.

Add the standards directory to PHP_CodeSniffer installed paths:

  • sudo phpcs –config-set installed_paths magento-ecg/coding-standard-master/

Run CodeSniffer:

  • phpcs –standard=Ecg –extensions=php,xml,phtml –report-full=<folder>/file.log www/lovingearth/app/code/local/

 

 

 

 

Cài Apache, PHP 5, MySQL trên Ubuntu

I. Cài đặt Apache

sudo apt-get install apache2

I.1) Cấu trúc thư mục cấu hình Apache trên Ubuntu

Mặc định trên Ubuntu, thư mục chứa các thiết lập của Apache sẽ nằm trong thư mục /etc/apache2. Trong thư mục đó, nó có một số thư mục và file cấu hình như sau:

  • conf-available/ – Thư mục này sẽ chứa các file thiết lập cấu hình sẵn của Apache trên Ubuntu, nhưng các thiết lập trong đây sẽ chưa được áp dụng vì Ubuntu không load thiết lập cấu hình trong thư mục này.
  • conf-enabled/ – Thư mục chứa các file thiết lập cấu hình của Apache trên Ubuntu đang được bật. Hãy hiểu là nếu thư mục này có một liên kết tượng trưng (symlink) qua một file module nào đó bên thư mục conf-available thì nó sẽ được bật.
  • mods-available/ – Thư mục chứa các file từng module của Apache trên Ubuntu nhưng chưa được bật.
  • mods-enabled/ – Thư mục chứa các file từng module của Apache trên Ubuntu đang được bật.
  • site-available/ – Thư mục chứa file cấu hình VirtualHost của Apache trên Ubuntu nhưng chưa được bật.
  • site-enabled/ – Thư mục chứa file cấu hình VirtualHost của Apache trên Ubuntu đang được bật.
  • apache2.conf – File cấu hình Apache trên Ubuntu.
  • envvars – File thiết lập các biến với giá trị sẵn để sử dụng trong các file cấu hình.
  • magic – File thiết lập của module mod_mime_magic trên Apache.
  • ports.conf – File cấu hình cổng mạng của Apache (mặc định là port 80).

II. Cài đặt PHP

Để cài đặt PHP và các module PHP cho Apache trên Ubuntu, hãy gõ lệnh sau:

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Và thiết lập cấu hình để nó ưu tiên index file index.php thay vì index.html bằng cách sửa file /etc/apache2/mods-enabled/dir.conf thành dưới đây (thêm index.php):

<IfModule mod_dir.c>
          DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

II.1) Cài thêm module cho PHP

sudo apt-cache search php5-

php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-json - JSON module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-readline - Readline module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-tidy - tidy module for php5
php5-xmlrpc - XML-RPC module for php5
php5-xsl - XSL module for php5
libphp5-embed - HTML-embedded scripting language (Embedded SAPI library)
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-apcu - APC User Cache for PHP 5
php5-enchant - Enchant module for php5
php5-exactimage - fast image manipulation library (PHP bindings)
php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php5-gdcm - Grassroots DICOM PHP5 bindings
php5-gearman - PHP wrapper to libgearman
php5-geoip - GeoIP module for php5
php5-gnupg - wrapper around the gpgme library
php5-imagick - ImageMagick module for php5
php5-imap - IMAP module for php5
php5-interbase - interbase/firebird module for php5
php5-intl - internationalisation module for php5
php5-lasso - Library for Liberty Alliance and SAML protocols - PHP 5 bindings
php5-librdf - PHP5 language bindings for the Redland RDF library
php5-mapscript - php5-cgi module for MapServer
php5-mcrypt - MCrypt module for php5
php5-memcache - memcache extension module for PHP5
php5-memcached - memcached extension module for PHP5, uses libmemcached
php5-midgard2 - Midgard2 Content Repository - PHP5 language bindings and module
php5-ming - Ming module for php5
php5-mongo - MongoDB database driver
php5-msgpack - PHP extension for interfacing with MessagePack
php5-mysqlnd - MySQL module for php5 (Native Driver)
php5-mysqlnd-ms - MySQL replication and load balancing module for PHP
php5-oauth - OAuth 1.0 consumer and provider extension
php5-pinba - Pinba module for PHP 5
php5-ps - ps module for PHP 5
php5-radius - PECL radius module for PHP 5
php5-redis - PHP extension for interfacing with Redis
php5-remctl - PECL module for Kerberos-authenticated command execution
php5-rrd - PHP bindings to rrd tool system
php5-sasl - Cyrus SASL Extension
php5-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP 5
php5-svn - PHP Bindings for the Subversion Revision control system
php5-sybase - Sybase / MS SQL Server module for php5
php5-tokyo-tyrant - PHP interface to Tokyo Cabinet's network interface, Tokyo Tyrant
php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
php5-xcache - Fast, stable PHP opcode cacher
php5-xdebug - Xdebug Module for PHP 5
php5-xhprof - Hierarchical Profiler for PHP5
apt-get install php5-xcache

III. Cài đặt MySQL Server

Hãy gõ lệnh dưới đây để cài đặt MySQL Server và module MySQL cho PHP.

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Trong khi cài đặt, MySQL sẽ hiển thị một giao diện để bạn thiết lập mật khẩu root cho MySQL.

III.1) Cài đặt phpMyAdmin

Nếu bạn muốn có thêm phpMyAdmin thì cài thêm bằng cách gõ lệnh:

Bật module mcrypt

php5enmod mcrypt

Và cài đặt phpMyAdmin

sudo apt-get install phpMyAdmin

Sau đó chọn apache2 và Enter.

Và hãy chọn Yes để thiết lập các cấu hình ban đầu cho phpMyAdmin.

Sau đó hãy nhập mật khẩu root của MySQL Server vào và Enter. Nếu nó có hỏi tạo mật khẩu phpmyadmin application thì cứ dùng cái mật khẩu root của MySQL Server luôn nhé.

Tiếp theo là mở file /etc/apache2/apache2.conf và chèn đoạn sau vào dưới cuối cùng:

IV. Cài đặt virtual host

IV.1. Thay đổi thư mục mặc định web root /var/www

- sudo mkdir -p /home/$user/www
- sudo chmod -R 755 /home/$user/www

IV.2. Tạo website test

- sudo mkdir -p /home/$user/www/test
Thay đổi quyền truy cập
- sudo chown -R $USER:$USER /home/$user/www/test/
- sudo chmod -R 755 /home/$user/www/test/
Tạo file index.php trong tu mục test
<?php 
 echo 'Hello test site';
?>

Tạo file virtual host
- cd /etc/apache2/sites-available/
- sudo cp 000-default.conf local-test.com.conf

Sửa file local-test.com.conf 
<VirtualHost *:80>
    ServerAdmin admin@local-test.com
    ServerName local-test.com
    ServerAlias www.local-test.com
    DocumentRoot /home/truongnguyen/www/test

    <Directory /home/truongnguyen/www/test>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
</VirtualHost>

Chỉnh sửa local host file
- sudo gedit /etc/hosts
127.0.0.1   localhost
127.0.0.1   local-test.com

Restart apache
- sudo service apache2 restart

Truy cập address http://local-test.com.
Nếu nội dung hiển thị "Hello test site" là thành công