Category: Japanese

Tạo Virtual host on window

  1. File httpd.conf:

LoadModule php5_module “C:/php-5.6.23-Win32-VC11-x64/php5apache2_4.dll”
AddHandler application/x-httpd-php .php
#configure the path to php.ini
PHPIniDir “C:/php-5.6.23-Win32-VC11-x64”

Include conf/extra/httpd-vhosts.conf

2. File httpd-vhosts.conf: xóa hết nội dung sample của file

<Directory d:/SOFTWARE/PHP/wordpress-4.5.3/wordpress>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

<VirtualHost *:80>
DocumentRoot “d:/SOFTWARE/PHP/wordpress-4.5.3/wordpress/”
#ErrorLog “logs/”
#CustomLog “logs/” common


3. File host: 

Vagrant Key inserted! Disconnecting and reconnecting using new SSH key… default: Warning: Authentication failure. Retrying…

tham khao:


  • None of the above worked for me. Somehow the box had the wrong public key added in the vagrant user authorised_keys file.

    If you can still ssh on the box with the vagrant password (password is vagrant), i.e.

    ssh vagrant@localhost -p 2222

    then copy the public key content from to the authorised_keys file with the following command

    echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > .ssh/authorized_keys

    When done exit the VM and try vagrant ssh again. It should work now.

  • Hoặc:


Run the following commands in guest machine/VM:

wget -O ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown -R vagrant:vagrant ~/.ssh

Then do vagrant halt. This will remove and regenerate your private keys.

(These steps assume you have already created or already have the ~/.ssh/ and ~/.ssh/authorized_keys directories under your home folder.)

= >Buoc tren là sinh key moi, sau đó them vào file vagrant de ngan vagrant insert key moi:

config.ssh.private_key_path = “E:/Vagrant/Home/insecure_private_key”
config.ssh.forward_agent = true
config.ssh.insert_key = false

How To Configure Static IP On CentOS 6

## Configure eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

NAME=”System eth0″
## Configure Default Gateway
# vi /etc/sysconfig/network

## Restart Network Interface

/etc/init.d/network restart

## Configure DNS Server
# vi /etc/resolv.conf

nameserver # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

Installing PostgreSQL 9.4 And phpPgAdmin In CentOS 7/6.5/6.4


PostgreSQL is a powerful, open-source object-relational database system. It runs under all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS, Solaris, Tru64), and Windows OS.

PostgreSQL 9.4 has been released last week with major enhancements, fixes, and features. Read what is new in PostgreSQL 9.4 here.

In this handy tutorial, let us see how to install PostgreSQL 9.4 on CentOS 7/6.5/6.4 server.

Install PostgreSQL

Go to the PostgreSQL repository download page, and add the PostgreSQL 9.4 repository depending upon your server architecture.

For CentOS 6.x 32bit:
rpm -Uvh
For CentOS 6.x 64bit:
rpm -Uvh
For CentOS 7 64bit:
rpm -Uvh

Update the repository list using command:

yum update

Now, Install postgresql with the following command:

yum install postgresql94-server postgresql94-contrib

Initialize postgresql database using following command:

On CentOS 6.x systems:
service postgresql-9.4 initdb
On CentOS 7 systems:
/usr/pgsql-9.4/bin/postgresql94-setup initdb

Then, start postgresql service and make it to start automatically on every reboot.

On CentOS 6.x systems:
service postgresql-9.4 start
chkconfig postgresql-9.4 on
On CentOS 7 systems:
systemctl enable postgresql-9.4
systemctl start postgresql-9.4

Adjust Iptables/Firewall

Next, adjust iptables to access postgresql from remote systems.

On CentOS 6.x systems:
vi /etc/sysconfig/iptables

Add the following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Save and exit the file. Restart iptables service.

service iptables restart
On CentOS 7 systems:
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

Adjust SELinux

Run the following command to make PostgreSQL work if SELinux enabled on your system.

setsebool -P httpd_can_network_connect_db 1

You may not login to PostegreSQL if you didn’t run the above command.

Access PostgreSQL command prompt

The default database name and database user are “postgres”. Switch to postgres user to perform postgresql related operations:

su - postgres

To login to postgresql, enter the command:


Sample Output:

psql (9.4.0)
Type "help" for help.

To exit from posgresql prompt, type \q following by quit to return back to the Terminal.

Set “postgres” user password

Login to postgresql prompt,

su - postgres

.. and set postgres password with following command:

postgres=# \password postgres 
Enter new password: 
Enter it again: 
postgres=# \q

To install PostgreSQL Adminpack, enter the command in postgresql prompt:

postgres=# CREATE EXTENSION adminpack;

Create New User and Database

For example, let us create a new user called “senthil” with password “centos”, and database called “mydb”.

Switch to postgres user:

su - postgres

Create user senthil.

$ createuser senthil

Create database:

$ createdb mydb

Now, login to the psql prompt, and set password and Grant access to the database mydb forsenthil:

$ psql
psql (9.4.0)
Type "help" for help.
postgres=# alter user senthil with encrypted password 'centos';
postgres=# grant all privileges on database mydb to senthil;

Delete Users and Databases

To delete the database, switch to postgres user:

su - postgres

Enter command:

$ dropdb <database-name>

To delete a user, enter the following command:

$ dropuser <user-name>

Configure PostgreSQL-MD5 Authentication

MD5 authentication requires the client to supply an MD5-encrypted password for authentication. To do that, edit /var/lib/pgsql/9.4/data/pg_hba.conf file:

vi /var/lib/pgsql/9.4/data/pg_hba.conf

Add or Modify the lines as shown below

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all               md5
host    all             all             md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Restart postgresql service to apply the changes:

On CentOS 6.x systems:
service postgresql-9.4 restart
On CentOS 7 systems:
systemctl restart postgresql-9.4

Configure PostgreSQL-Configure TCP/IP

By default, TCP/IP connection is disabled, so that the users from another computers can’t access postgresql. To allow to connect users from another computers, Edit file/var/lib/pgsql/9.4/data/postgresql.conf:

vi /var/lib/pgsql/9.4/data/postgresql.conf

Find the lines:

#listen_addresses = 'localhost'
#port = 5432

Uncomment both lines, and set the IP address of your postgresql server or set ‘*’ to listen from all clients as shown below:

listen_addresses = '*'
port = 5432

Restart postgresql service to save changes:

On CentOS 6.x systems:
/etc/init.d/postgresql-9.4 restart
On CentOS 7 systems:
systemctl restart postgresql-9.4

Manage PostgreSQL with phpPgAdmin

phpPgAdmin is a web-based administration utility written in PHP for managing PosgreSQL.

phpPgAdmin is available only in PostgreSQL RPM repository. If you didn’t add PostgreSQL repository, you should add EPEL repository.

Follow the below link to install EPEL repository on CentOS 6.x.

For CentOS 7, refer the following link.

Or, simply enter the following command:

yum install epel-release

Update the repository using command:

yum update

Now, Install phpPgAdmin, enter the following command:

yum install phpPgAdmin httpd

Note: phpPgAdmin is case sensitive. Use upper and lower cases properly as shown in the above command.

By default, you can access phppgadmin using http://localhost/phpPgAdmin from your local system only. To access remote systems, do the following.

Edit file /etc/httpd/conf.d/phpPgAdmin.conf:

vi /etc/httpd/conf.d/phpPgAdmin.conf

Make the changes as shown below in the bold letters.

Alias /phpPgAdmin /usr/share/phpPgAdmin
<Location /phpPgAdmin>
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
        #Require host
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order deny,allow
        Allow from all
        # Allow from

Start or Restart Apache service:

On CentOS 6.x systems:
service httpd start
chkconfig httpd on
On CentOS 7 systems:
systemctl enable httpd
systemctl start httpd

Configure phpPgAdmin

Edit file /etc/phpPgAdmin/, and do the following changes. Most of these options are self-explanatory. Read them carefully to know why do you change these values.

vi /etc/phpPgAdmin/

Find the following line:

$conf['servers'][0]['host'] = '';

Change it as shown below:

$conf['servers'][0]['host'] = 'localhost';

And find the line:

$conf['extra_login_security'] = true;

Change the value to false:

$conf['extra_login_security'] = false;

Find the line:

$conf['owned_only'] = false;

Set the value as

$conf['owned_only'] = true;

Save and close the file. Restart postgresql service and Apache services.

On CentOS 6.x systems:
service postgresql-9.4 restart
service httpd restart
On CentOS 7 systems:
systemctl restart postgresql-9.4
systemctl restart httpd

Now open your browser and navigate to http://ip-address/phpPgAdmin. You will see the following screen.

phpPgAdmin - Mozilla Firefox_001

Login with users that you’ve created earlier. I already have created a user called “senthil”with password “centos” before, so I log in with user “senthil”.

phpPgAdmin - Mozilla Firefox_002

You may get an error called: Login failed.


This is because SELinux might restrict the users to log in to the PostgreSQL. Just enter the following command to get rid of this error.

setsebool -P httpd_can_network_connect_db 1

Now, you’ll be able to log in to the Dashboard without any problems.

This is how my phpPgAdmin dashboard looked.

phpPgAdmin - Mozilla Firefox_004

Log in with postgres user:

phpPgAdmin - Mozilla Firefox_005

That’s it. Now you’ll able to create, delete and alter databases graphically using phpPgAdmin easily.

FTP vagrant

Make sure your vagrant vm is running. Then:

vagrant ssh
sudo apt-get install vsftpd

Edit the ftp config file to enable authenticated users to ftp:

sudo nano /etc/vsftpd.conf

Then uncomment the following lines:


Save the file. (Control-x, y, return) Restart ftp with:

sudo /etc/init.d/vsftpd restart

After this, you should be able to install modules from the modules page. Login with “vagrant” for the username and password if/when asked.

Obviously, it’d be best if we didn’t have to do this.


Neu ko tao file dc thì:

If you don’t want to go further with your SELinux do not change it, so you will see as default /etc/selinux/config


then just run the commands as root or with sudo:

sudo setsebool -P ftpd_anon_write 1
sudo setsebool -P ftpd_full_access 1

Ghi chú install vagrant debug php
package box:
setup virtual host:
run update
yum update kernel*

sudo umount -f -a -t vboxsf: unmount all share
mount | grep vbox
mount.vboxsf html /var/www/html/ : mount folder

Neu ko co quyer: chinh sua file http.conf :
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted

—Access web tu ben ngoai vao:
sudo firewall-cmd –permanent –zone=public –add-service=http
sudo firewall-cmd –permanent –zone=public –add-service=https
sudo firewall-cmd –reload

cai driver
sudo yum install php-pdo
yum install php-pdo_pgsql

yum install php-mbstring (dùng cho hàm mb_strimwidth trongUtil::getProgramId)

yum install -y –enablerepo=remi,remi-php56 install php-mssql

setup driver sqlserver:

CentOS 6.x and Microsoft SQL Server ODBC Linux driver

ln -s /etc/httpd/sites-available/ /etc/httpd/sites-enabled/
cp /var/www/ /var/www/ : copy file

Change language

sudo chown -R apache:apache /var/www/
sudo chmod a+x /path/to/dir : thay doi quyen cho folder
shutdown -h now
reboot -h now

sudo vi /etc/httpd/conf/httpd.conf
sudo vi /etc/httpd/conf.d/brostools.conf
sudo vi /etc/hosts
sudo vi /home/release/main/index.html
sudo /etc/init.d/httpd restart
sudo vi /var/log/httpd/error_log

them 3 lines vao file : /etc/rc.d/init.d/httpd
export BT_SYSTEM_RUN_TYPE=VietnamDev

sudo wget

Neu apache ko co quyen access folder vagrant thi:
/etc/sysconfig/selinux => chuyen sang disabled

sudo chown -R apache:apache /var/www/bros/web/bros_tools/app/htdocs
sudo chown -R apache:apache /var/www/bros/api/bros_rest_api/htdocs
chcon -R -h -t httpd_sys_content_t /var/www/bros/web/bros_tools/app/htdocs
Yum erase php php-pear php-mysql php-cli php-common php-pdo php-mysql
install php 5.4 on centos6

mount -t vboxsf -o uid=’id -u apache’,gid=’id -g apache’,dmode=755,fmode=644 /var/www/bros/web/bros_tools/app/htdocs /var/www/bros/web/bros_tools/app/htdocs

# rpm -Uvh
yum install php54w.x86_64 php54w-cli.x86_64 php54w-common.x86_64 php54w-gd.x86_64 php54w-ldap.x86_64 php54w-mbstring.x86_64 php54w-mcrypt.x86_64 php54w-mysql.x86_64 php54w-pdo.x86_64

khi copy box sang may khac bi loi, ko mount duoc:
1. rm -rf /etc/udev/rules.d/70-persistent-net.rules
2. rm -rf /etc/sysconfig/network-scripts/ifcfg-eth1
3. rm -rf /etc/sysconfig/network-scripts/ifcfg-eth2
4. vim /etc/sysconfig/network-scripts/ifcfg-eth1

Setup Vagrant, Linux, PHP, XDebug

list file: ls -al /etc
de biet path hien tai: pwd
sudo yum install httpd
sudo systemctl start httpd.service
start apache khi boot system: sudo systemctl enable httpd.service
sudo systemctl restart httpd.service
sudo yum install mariadb-server mariadb
start service: sudo systemctl start mariadb
remove mot vai caidat default: sudo mysql_secure_installation
sudo yum install php php-mysql
List module va extension: yum search php-
yum info package_name : xem thong tin package
yum info php-fpm : mo ta chi tiet package
sudo yum install php-fpm: cai package php-fpm
sudo yum install package1 package2 … : install nhieu package
sudo vi /var/www/html/info.php : tao file
:$ => di den cuoi file
😡 (quit and save)
:q => exit without save
i => insert mode
esc: thoat insert mode
sudo rm /var/www/html/info.php =>delete file

$ vagrant reload
Neu loi: /sbin/mount.vboxsf: mounting failed with the error: No such device => :
sudo yum update -y
sudo yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r) dkms -y
vagrant plugin install vagrant-vbguest

vagrant file: “private_network”, ip: “” “private_network”, ip: “”
config.vm.synced_folder “./shared/www”, “/var/www/html/”, :mount_options => [“dmode=777”, “fmode=777”]
config.vm.synced_folder “./shared/logs”, “/logs”, :mount_options => [“dmode=777”, “fmode=777”]

link tham khao:

Các câu lệnh Github

Sao chép (clone) một repository

  • Để tạo 1 repository mới: git init
  • Clone 1 repository có sẵn ở trên máy cục bộ: git clone /đường-dẫn-đến/repository/

* Nếu repository đó ở máy chủ khác thì bạn hãy gõ dòng lệnh sau:git clone tênusername@địachỉmáychủ:/đường-dẫn-đến/repository

Thêm (add) & commit

  • Thêm nó vào chỉ mục Index: git add <tên-tập-tin> <=> git add *
  • Commit: git commit -m "Ghi chú Commit"

Đẩy (push) các thay đổi

  • Để gửi những thay đổi đến repository remote: git push origin master

* Thay đổi master bằng bất cứ nhánh nào mà bạn muốn đầy những thay đổi đến.

  • Nếu bạn chưa clone một repository hiện có và muốn kết nối repository của bạn đến máy chủ remote, bạn phải thêm nó với: git remote add origin <máy-chủ> .Bây giờ bạn đã có thể đẩy các thay đổi của mình vào máy chủ đã chọn.

Nhánh (Branch)

  • List all branch:

git branch

  • Tạo một nhánh mới và đặt tên là “feature_x” và chuyển qua nhánh đó (từ master) bằng cách (create your branch locally): git checkout -b feature_x
  • Push new branch to remote:

git push <remote-name> <branch-name>

  • Trở lại nhánh master: git checkout master
  • Delete branch:

git push origin --delete <branchName>

Cập nhật & trộn (update & merge)

  • Để cập nhật repository cục bộ của bạn và commit mới nhất, thực thi: git pull trong thự mục đang làm việc để lấy về (fetch)trộn (merge) các thay đổi ở remote
  • Để trộn một nhánh khác vào nhánh đang hoạt động (vd: master), sử dụng:

   git merge <nhánh>

Trong cả hai trường hợp, git cố gắng trộn tự động (auto-merge) các thay đổi. Không may, điều này không phải lúc nào cũng làm được và thường dẫn đến xung đột. Trách nhiệm của bạn là trộn các xung đột đó thủ công bằng cách chỉnh sửa các tập tin được hiển thị bởi git. Sau khi thay đổi, bạn phải đánh dấu chúng là đã được trộn (merged) với lệnh:

git add <tên-tập-tin>

trước khi trộn các thay đổi, bạn có thể xem trước chúng bằng cách:

git diff <nhánh_nguồn> <nhánh_mục_tiêu>

Gắn nhãn (tagging)

  • Nên tạo nhãn (tags) khi phát hành phần mềm. đây là khái niệm được biết đến, đã từng có trên SVN. Bạn tạo tag mới tên là 1.0.0 bằng cách:

git tag 1.0.0 1b2e1d63ff

* Chuỗi 1b2e1d63ff là 10 ký tự đầu tiên của mã commit (commit id) mà bạn muốn tham chiếu đến bằng nhãn của bạn. Bạn có thể lấy mã commit với lệnh:

git log

           bạn cũng có thể sử dụng ít ký tự hơn từ mã commit, nó chỉ cần phải là duy nhất

Thay thế các thay đổi cục bộ

  • Trong trường hợp bạn làm sai điều gì đó, bạn có thể thay thế các thay đổi cục bộ bằng lệnh:

git checkout -- <tên-tập-tin>

* lệnh này thay thế những thay đổi trong “tree” đang làm việc với nội dung mới nhất của HEAD. Các thay đổi đã được thêm vào chỉ mục, kể cả các tập tin mới, điều này sẽ được giữ lại

  • Hủy tất cả thay đổi và commit cục bộ, lấy về (fetch) lịch sử gần đây nhất từ máy chủ và trỏ nhánh master cục bộ vào nó như sau:

git fetch origin

git reset --hard origin/master

Continue reading “Các câu lệnh Github”