2012年2月14日 星期二

SSH SCP 傳資料方式

scp是跑ssh
scp -r 來源  目標
如果是遠端
要加入登入的帳號
範例:
scp -r root@192.168.1.1:/etc /tmp

2012年2月13日 星期一

安裝 Java6 JDK 於 Ubuntu 11.10

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugi

安裝PDO FOR PHP在UBUNTU上

For some reason there aren’t any PDO packages for PHP 5 on Ubuntu 6.10. They’re pretty easy to install from PECL but you might need to install the dev version of your database client libraries. Below is what I had to type to install PDO with the MySQL driver.

% sudo apt-get install libmysqlclient15-dev
% sudo pecl install pdo
% sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.
extension=pdo.so
extension=pdo_mysql.so

2012年2月12日 星期日

MYSQL PHPMYADMIN 更換WEB管理介面PORT


remove symlink to phpmyadmin.conf file
Code:
rm /etc/apache2/conf.d/phpmyadmin.conf
make apache listen on port 81 (or what ever you desire.)
Code:
sudo nano /etc/apache2/ports.conf
Add "Listen 81" to the file.
Code:
user@mythtv:/etc/apache2$ cat ports.conf 
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80
Listen 81
<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>
Now create the vHost:
Code:
sudo vi /etc/apache2/sites-available/phpmyadmin
add the following to the file: 
Code:
<VirtualHost *:81>
  ServerName phpmyadmin
  DocumentRoot /var/www-81
</VirtualHost>
Enable the vHost:
Code:
sudo a2ensite phpmyadmin
Restart Apache:
Code:
sudo service apache2 restart
Create a symlink to the phpmyadmin directoy:
Code:
cd /var/www-81
sudo ln -s /usr/share/phpmyadmin/
At this point navigating to http://ip/phpmyadmin should not show the page. but http://ip:81/phpmyadmin should.


並將/etc/mysql/apache2.conf 裡的Alias移除!

This is just a friendly warning and not really a problem (as in that something does not work).
If you insert a
ServerName localhost   
in either httpd.conf or apache2.conf in /etc/apache2 and restart apache the notice will disappear.
If you have a name inside /etc/hostname you can also use that name instead of localhost.

And it uses 127.0.1.1 if it is inside your /etc/hosts:
127.0.0.1 localhost
127.0.1.1 myhostname
Troubleshooting Apache
If you get this error:
apache2: Could not determine the server's fully qualified domain name, 
using 127.0.0.1 for ServerName
then use a text editor such as "sudo nano" at the command line or "gksudo gedit" on the desktop to create a new file,
sudo nano /etc/apache2/conf.d/fqdn
or
gksu "gedit /etc/apache2/conf.d/fqdn"
then add
ServerName localhost
to the file and save. This can all be done in a single command with the following:
 echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn

2012年2月11日 星期六

MySQL安裝指南

安裝MySQL

sudo apt-get install mysql-server

這個應該很簡單了,而且我覺得大家在安裝方面也沒什麼太大問題,所以也就不多說了,下面我們來講講配置。

配置MySQL

注意,在Ubuntu下MySQL缺省是只允許本地訪問的,如果你要其他機器也能夠訪問的話,那麼需要改變/etc/mysql/my.cnf配置文件了!下面我們一步步地來:

默認的MySQL安裝之後根用戶是沒有密碼的,所以首先用根用戶進入:

$mysql -u root

在這裏之所以用-u root是因為我現在是一般用戶(firehare),如果不加-u root的話,mysql會以為是firehare在登錄。注意,我在這裏沒有進入根用戶模式,因為沒必要。一般來說,對mysql中的數據庫進行操作,根本沒必要進入根用戶模式,只有在設置時才有這種可能。

進入mysql之後,最要緊的就是要設置Mysql中的root用戶密碼了,否則,Mysql服務無安全可言了。

mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";

注意,我這兒用的是123456做為root用戶的密碼,但是該密碼是不安全的,請大家最好使用大小寫字母與數字混合的密碼,且不少於8位。

這樣的話,就設置好了MySQL中的root用戶密碼了,然後就用root用戶建立你所需要的數據庫。我這裏就以xoops為例:

mysql>CREATE DATABASE xoops;

mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@localhost IDENTIFIED BY "654321";

這樣就建立了一個xoops_roots的用戶,它對數據庫xoops有着全部權限。以後就用xoops_root來對xoops數據庫進行管理,而無需要再用root用戶了,而該用戶的權限也只被限定在xoops數據庫中。

如果你想進行遠程訪問或控制,那麼你要做兩件事:

其一:

mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@"%" IDENTIFIED BY "654321";

允許xoops_root用戶可以從任意機器上登入MySQL。

其二:

$sudo gedit /etc/mysql/my.cnf

老的版本中

>skip-networking => # skip-networking

新的版本中

>bind-address=127.0.0.1 => bind-address= 你機器的IP

這樣就可以允許其他機器訪問MySQL了。

查詢UBUNTU檔案大小指令

du --max-depth=1 -xh | sort -n