Tạo example cronjob chạy trên Ubuntu 14.04

Tạo file test-cron.php dùng ghi ngày tháng vào file log

Cronjob ubuntu 14.04

File test.log

crontab-4

Mở file crontab

  • sudo crontab -u www-data -e

Cron job o Ubuntu 14.04

Thêm dòng config

Cron job o Ubuntu 14.04

Notes : * * * * * cronjob sẽ chạy từng phút.

Good luck ^_^

Advertisements

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/

 

 

 

 

Thiết lập Password Authentication Apache trên Ubuntu 14.04

Cài Đặt Apache Utilites

  • sudo apt-get update
  • sudo apt-get install apache2 apache2-utils

Tạo Password File

  • sudo htpasswd -c /etc/apache2/.htpasswd <username>

Selection_009– Kiểm tra file .htpasswd

  • sudo vi /etc/apache2/.htpasswd

Selection_010 Selection_011

Cấu hình Apache Password Authentication

1. Dùng Virtual Host

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/truongnguyen/www/lara5111
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /home/truongnguyen/www/lara5111>
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
         AuthType Basic
         AuthName "Login"
         AuthUserFile /etc/apache2/.htpasswd
         Require valid-user
    </Directory>
</VirtualHost>

- Restart apche
- sudo service apache2 restart

2. Dùng .htaccess

Thêm 4 dòng code vào đầu file .htaccess

AuthUserFile /etc/apache2/.htpasswd
AuthType Basic
AuthName "Login"
Require valid-user
Done ^_^

Cài đặt Laravel 5 trên ubuntu 14.04

Các gói hỗ trợ và thành phần phụ thuộc của Laravel được quản lý bởi Composer. Do đó, trước khi sử dụng Laravel, bạn hãy đảm bảo đã cài đặt Composer trên máy của mình.

1. Cài đặt bằng cách tải về từ source Github:

Tải về các bản release trên Github, và giải nén folder www/lara5111 sau đó chạy lệnh:

  • cd www/lara5111
  • composer install

lara5111_006

  • sudo chmod -R 777 bootstrap/cache/
  • sudo chmod -R 777 storage/

– Set up virtual host

  • cd /etc/apache2/sites-available/
  • sudo vi local-lara5.com.conf

-Add content to file local-lara5.com.conf

<VirtualHost *:80>
ServerAdmin admin@local-lara5.com
ServerName local-lara5.com
ServerAlias http://www.local-lara5.com
DocumentRoot /home/truongnguyen/www/lara5111

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

–  Update APP_KEY in file config/app.php

lara5111_008

– ‘key’ => env(‘APP_KEY’, ‘NYTxVnzoAtbslwrurSJ0SFt73PT5449C’)

– Run address http://local-lara5.com

Done ^_^

Cài đặt composer trên Ubuntu 14.04

Step 1 — Installing the Dependencies

Before we download and install Composer, we need to make sure our server has all dependencies installed.

First, update the package manager cache by running:

  • sudo apt-get update

Now, let’s install the dependencies. We’ll need curl in order to download Composer and php5-cli for installing and running it. git is used by Composer for downloading project dependencies. Everything can be installed with the following command:

  • sudo apt-get install curl php5-cli git

You can now proceed to the next step.

Step 2 — Downloading and Installing Composer

Composer installation is really simple and can be done with a single command:

This will download and install Composer as a system-wide command named composer, under /usr/local/bin. The output should look like this:

Output
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

To test your installation, run:

  • composer

And you should get output similar to this:

Output
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0-dev (9859859f1082d94e546aa75746867df127aa0d9e) 2015-08-17 14:57:00

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --profile             Display timing and memory usage information
 --working-dir (-d)    If specified, use the given directory as working directory.

. . .

This means Composer was succesfully installed on your system.

Remove index.php from Magento URLs

1) Let’s Change a Setting, Admin

The first thing you need to do is to login to your Magento admin panel (index.php/admin) in order to change a very simple setting which will let Magento know that you intend to use URL rewriting throughout your store rather than their ugly default URLs.

Login, and change this setting:

Go to System > Configuration > Web > Search Engine Optimization

Use Web Server Rewrites: YES

That was easy, wasn’t it? Okay, now for the final step.

2) Let’s Use a .htaccess File to Rewrite the URLs

The final step involves creating a .htaccess file in the Magento installation folder in order to compliment the settings you changed within your admin settings earlier, and this will actually rewrite the URLs. Choose the applicable .htaccess version below.

If your Magento store is installed in root (public_html), use this:

RewriteEngine On RewriteBase / RewriteRule ^index.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

If your Magento store is installed in a subfolder (public_html/shop), use this:

RewriteEngine On RewriteBase /shop/ RewriteRule ^index.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /shop/index.php [L]

You’re done – hope that helps!

Cài đặt Phalcon Developer Tools on Linux

Download

You can download a cross platform package containing the developer tools from the Download section. Also you can clone it from Github.

Open a terminal and type the commands below:

linux-1

Then enter the folder where the tools were cloned and execute ”. ./phalcon.sh”, (don’t forget the dot at beginning of the command):

linux-2

Create a symbolink link to the phalcon.php script:

ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon

chmod ugo+x /usr/bin/phalcon

Congratulations you now have Phalcon tools installed!