Category Archives: Linux

Linux Note

Output to file with warning and error message

# php mycode.php >> myLog 2>&1

2&1 : redirects stderr to the same place as stdout

Posted in Linux, Tech Note | Tagged , | Leave a comment

Off php engine for upload folder

<Directory /home/www/upload>
    Options -ExecCGI
    php_flag engine off
</Directory>

Posted in Linux, Tech Note | Tagged , , | Leave a comment

Linux compress / decompress a file

Compress

1 Put all file or directory into single file.

# tar -cvf COMPRESS_FILE_NAME.tar FILE_NAME

2. Compress (Zip)

# gzip -f COMPRESS_FILE_NAME.tar

=======================================================

Decompress

1. Unzip

# gunzip COMPRESS_FILE_NAME.tar.gz

2. Release single file back

# tar -xvf COMPRESS_FILE_NAME.tar

Posted in Linux, Tech Note | Tagged , , , | Leave a comment

Enable to access Mysql from external

If you did not set up root password, you need to setup root password first.

Setup Root Password

# mysql -u root -p

mysql> show Databases;

mysql> use mysql;

mysql> update user set password = ‘YOUR_PASSWORD’ where user = ‘root’;

mysql > exit;

Mysql restart

# /etc/init.d/mysql restart

================================================================================

Enable to access Mysql from external

mysql> use mysql;

mysql> show tables;

+—————————+
| Tables_in_mysql           |
+—————————+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user |
+—————————+

There is user table which contain all user permission.

mysql> select host,user from user;

+———————–+——+
| host                  | user |
+———————–+——+
| 10.0.111.10              | root |
| localhost             |      |
| localhost             | root |
| localhost.localdomain |      |
| localhost.localdomain | root |
+———————–+——+

Now with that setup, only 10.0.111.10 IP user can access mysql.

% means allow all numbers.

so if you want to make set up 10.0.111.ALL Ip users can access,

update root host like 10.0.111.%

mysql> update user set host=’10.0.111.%’ where user = ‘root’ and host=’10.0.111.10′

Warning : Local host and root field required! do not update or delete!

Try to connect mysql from external computer.

$conn = mysql_connect('10.0.111.10','root','XXXXX');
if(!$conn){
    die('Connection faild! ' . mysql_error());
}
echo "Connected!";
mysql_close($conn);

output :: Connection! =3 :)

Posted in Linux, Tech Note | Tagged , , | Leave a comment

Install FTP Server on Linux

Install

# yum install vsftpd

Setup ftp environment

# vi /etc/vsftpd/vsftp.conf

Service Start

# /etc/init.d/vsftpd restart

Posted in Linux, Tech Note | Tagged , | Leave a comment

Linux Open port #

# vi /etc/sysconfig/iptables

Append rule

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

Save and restart ipTables

# /etc/init.d/iptables restart

Verify that open is open

# netstat -tulpn | less

Posted in Linux, Tech Note | Tagged | Leave a comment

Set start program on linux

#ntsysv

Posted in Linux, Tech Note | Tagged , | Leave a comment

How to set hostname in Linux

# vim /etc/sysconfig/network

Posted in Linux, Tech Note | Tagged | Leave a comment

How to escape VIM freeze cause press Ctrl+S key

Press Ctrl + q key :)

Posted in Linux, Tech Note | Tagged , | 2 Comments

How to install APM on Centos

1. Install MYSQL

-Install Mysql using YUM

# yum -y install mysql mysql-server

(-y : Agree with installing package)

– Regist Mysql to serivce

# chkconfig –levels 235 mysqld on

– run Mysql

# /etc/init.d/mysqld start

– Setup Mysql (root) password

# mysqladmin -u root password 12345

2. Install Apache

-Install Apache using YUM

# yum -y install httpd

-Regist Apache to service

# chkconfig –levels 235 httpd on

3. Install PHP

– Install PHP using YUM

# yum -y install \

php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

4. Install PHPMYADMIN

Phpmyadmin may not in the default package store. So we need to download it first.

To to http://packages.sw.be/rpmforge-release/ and check right version for you.

– Download package

# wget \

http://packages.sw.be/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

– Run the package

# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

– Install PHPMYADMIN

# yum -y install phpmyadmin

– Setup PHPMYADMIN enviorment

# vi /etc/httpd/conf.d/phpmyadmin.conf

—— Modify like blow —

#
#  Web application to manage MySQL
#
#<Directory “/usr/share/phpmyadmin”>
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>
#
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

– Change PHPMYADMIN AUTH method

# vi /usr/share/phpmyadmin/config.inc.php

/* Authentication type */
$cfg[‘Servers’][$i][‘auth_type’] = ‘http’;

Finally! RUN Apache

# /etc/init.d/httpd start

Test LAMP

# echo “<?php phpinfo(); ?>” > /var/www/html/phpinfo.php

Posted in Linux, Tech Note | Tagged , , | 1 Comment