2020年1月21日 星期二
Install HestiaCP
wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh
2.
apt-get upgrade
3.
apt-get update && apt-get install ca-certificates
4.
bash hst-install.sh --multiphp yes -f -y no -e noreply@aaa.com -p PassWord -s hestia.aaa.com
2019年10月30日 星期三
ISPconfig Postfix
root> vi /etc/postfix/master.cf
[...]
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - - - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
[...]
root> service postfix restart
2016年10月6日 星期四
sqLite 匯出匯入
//指定db檔案
sqlite3 /home/data/p1.db
//匯出SQL
sqlite>.output /home/data/p1.sql
sqlite>.dump
sqlite>.quit
//指定db檔案
sqlite3 /home/data/p1.db
//SQL匯入
sqlite>.read /home/data/p1.sql
sqlite>.quit
//指定db檔案
sqlite3 /home/data/p1.db
//設定分割符號
sqlite>.separator ";"
//匯入CSV檔案
sqlite>.import /home/data/p1.csv [tablename]
2014年7月2日 星期三
sshpass 經由 SSH 連不需要再次輸入密碼
sshpass -p [Password] rsync -p --progress --delete /usr/bin/ssh -aS /home/web/html aecnerwp@123.123.123.123:/home/web
sshpass -p [Password] rsync -p --delete /usr/bin/ssh -aS /home/web/html aecnerwp@123.123.123.123:/home/web
2011年6月15日 星期三
Rsync 使用
1.安裝
yum install xinetd rsync -y
2.修改 /etc/xinetd.d/rsync
disable = yes 改為 disable = no
3.新建或是修改 /etc/rsyncd.conf
加入以下
#============================
#備份模組
[bkusermodule]
#備份之檔案的存放路徑
path = /home/bkhome/html
ignore errors
read only = no
list = no
#驗證的用戶名稱 (此名稱只需存在於密碼檔裡面)
auth users = bkuser
#執行程式時所使用的用戶及群組名稱,備份之後檔案的擁有者及群組
uid = bkhome
gid = bkhome
#密碼檔的位置
secrets file = /etc/rsync.password
#============================
4.設定密碼檔及權限
echo "bkuser:1234567" >> /etc/rsync.password
chmod 600 /etc/rsync.password
5.啟動
service xinetd restart
rsync --daemon
6.增加到啟動檔案
echo "rsync --daemon" >> /etc/rc.d/rc.local
[Client端-192.168.102.2]
1.建密碼檔 /etc/password.txt 內容為 1234567
2.設定密碼檔權限
chmod 600 /etc/password.txt
3.開始同步
rsync 參數 備份來源位置 帳號@SERVER位置::備份模組
windows密碼檔用法
rsync -avHSz --delete /home/php bkuser@192.168.102.242::bkusermodule < /etc/password.txt
Linux密碼檔用法
rsync -avHSz --delete --password-file=/etc/password.txt /home/php bkuser@192.168.102.242::bkusermodule
.
2011年5月17日 星期二
2011年5月14日 星期六
NcFTP
1.rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
2.yum list *NCFTP*
3.yum install ncftp
==使用==
FTP整個資料夾
ncftpput -u [ftp_id] -p [ftp_pw] -A -R -m -V [ftp_ip] [遠端路徑] [本地檔案]
實例:
ncftpput -u webuser -p ftp_pwd -A -R -m -V 192.168.50.123 /home/webuser ./webuser/*
==官方網址=
http://www.ncftp.com/ncftp/
2009年10月22日 星期四
2009年4月7日 星期二
MySQL Big5 轉 utf8
所以為了解決亂碼問題,在PHP 與 MySQL 建立連線時,於 query 之前先執行:
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
mysql_query("SET CHARACTER_SET_CONNECTION=utf8");
mysql_query("SET CHARACTER_SET_RESULTS=utf8");
如上三列編碼都一樣時,可直接執行下列
mysql_query("SET NAMES utf8");
◎ MySQL資料庫big5轉utf8:
Step1:首先把資料dump出來
由於先前資料是存成latin1,所以dump出來後要用iconf或piconf把他轉成UTF-8,記得dump出來時要加上-default-character-set=latin1
#mysqldump -u 帳號 -p --default-character-set=latin1 資料庫 >output.sql
Step2:big5轉成utf8
如果原先是Big5的資料, dump出來後就直接把Big5轉成UTF-8即可
#piconv -f big5 -t utf8 output.sql >utf8.sql
如果原先是UTF-8的資料,dump出來後要先轉成Big5後,再把他轉成UTF-8,因為原先dump出來的是偽裝成UTF-8的lantin1不是真正的UTF-8
#mysqldump -u 帳號 -p -default-character-set=latin1 資料庫 >output.sql
#piconv -f utf8 -t big5 output.sql > big5.sql
#piconv -f big5 -t utf8 big5.sql >utf8.sql
Step3:修改sql檔
1、修改轉成的sql檔中所產生的‘’\”及換行的問題(有時換行時會成‘\n’)
2、在dump出來的sql檔最前面加上:
SET NAMES utf8;
SET CHARACTER_SET_CLIENT=utf8;
SET CHARACTER_SET_RESULTS=utf8;
:1,$s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/g
:1,$s/latin1/utf8/gc
:1,$s/許\\/許/g
:1,$s/功\\/功/g
:1,$s/蓋\\/蓋/g
:1,$s/餐\\/餐/g
:1,$s/愧\\/愧/g
:1,$s/擺\\/擺/g
:1,$s/穀\\/穀/g
:1,$s/淚\\/淚/g
:1,$s/豹\\/豹/g
:1,$s/珮\\/珮/g
:1,$s/俞\\/俞/g
再來把每個資料表後面的TYPE=MyISAM是否有DEFAULT CHARSET=latin1;
若沒有請改為ENGINE=MyISAM DEFAULT CHARSET=utf8;
Step4:建立新的資料庫
方法1. SQL語法
CREATE DATABASE `資料庫` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
方法2. 用phpMyAdmin建立資料庫的,建立時”校對”要選utf8_general_ci
步驟五:import資料
方法1. SQL語法
#mysql -u 帳號 -p 資料庫 < utf8.sql
方法2. 直接用phpMyAdmin把他import進去了,import時記得文字編碼檔案要選utf8即可。不過使用phpMyAdmin import 有檔案大小的限制,可先把sql檔分成幾個檔案。
◎ 最後記得檢查看MySQL的my.cnf設定檔內要加入以下設定
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
2009年2月25日 星期三
.htaccess 的用處
例如:
===============================================
DirectoryIndex index.html index.htm index.php
AddType application/x-httpd-php .html .htm
php_value auto_prepend_file ./before.php
php_value default_charset utf-8
php_flag register_globals on
===============================================
上面意思是.
1.預設網頁的指定,依序排列.
2.讓 .html, .htm 跟 .php 一樣, 輸出前要經過處理.
3.在每個檔案前面都加上 before.php
4.設定預設語系為 UTF-8
5.設定php.ini的參數register_globals為on
2008年11月20日 星期四
破解
function crack( ){
global $gbl;
global $sgbl;
global $login;
global $ghtml;
$license = $login->getObject( "license" );
$name = $license->licensecom_b->lic_ipaddress;
if ( stristr($name,"YuMAX")) {
return;
}
$license->licensecom_b->lic_ipaddress = "For YuMAX ".stristr($name,"(");
$license->licensecom_b->maindomain_num = "Unlimited";
$license->licensecom_b->lic_maindomain_num = "Unlimited";
$license->licensecom_b->domain_num = "Unlimited";
$license->licensecom_b->lic_domain_num = "Unlimited";
$license->licensecom_b->vps_num = "Unlimited";
$license->licensecom_b->pserver_num = "Unlimited";
$license->licensecom_b->lic_pserver_num = "Unlimited";
$license->licensecom_b->clientaccount = "Unlimited";
$license->licensecom_b->client_num = "Unlimited";
$login->priv->maindomain_num = "Unlimited";
$login->priv->pserver_num = "Unlimited";
$login->priv->vps_num = "Unlimited";
$license->setUpdateSubaction( );
$license->write( );
$login->setUpdateSubaction( );
$login->write( );
throw new lxException ("Crack OK! you have Unlimited domain/vps and full fuction now!", "");
exit;
}
include_once( "../htmllib/coredisplaylib.php" );
print_time( "start" );
print_time( "start", "Start" );
crack();
display_exec( );
2008年10月4日 星期六
在 Linux 中增加 Swap 檔案的空間.
先決定需要新增多大的 Swap 空間, 再來決定這個 Swap 檔案的大小. 例如:1024MB.
STEP 2:
[以root的身份輸入下列指令.]
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
STEP 3:
[輸入以下指令使swapfile這個檔案成為 Swap 檔案.]
mkswap /swapfile
STEP 4:
[啟動這個 Swap 檔案.]
swapon /swapfile
STEP 5:
[設定在開機時能自動啟動這個 Swap 檔案. 使用 vi 去編輯 /etc/fstab ,並加入下列內容.]
/swapfile swap swap defaults 0 0
STEP 6:
使用top 這個指令去查看 Swap 是否有增加.
2008年9月30日 星期二
MySQL 匯出匯入指令
mysqldump -u userid -e -p db_Name > xxxxx.sql
[有條件匯出]
mysqldump -u帳號 -p密碼 -h主機 資料庫 資料表 -w "sql條件" > 出輸路徑及檔案
例:
mysqldump -uroot -p123456 -hlocalhost -e AREA_UTF8 city -w "c_id<10 " > /home/web/a.txt
--no-create-info,-t
只導出資料,而不添加 CREATE TABLE 語句;如果導出格式為SQL語句,則只有insert into部分。
--no-data,-d
不導出任何資料,只導出資料庫結構
--quick,-q
在導出大量資料很有用,強制從 MySQL Server 查詢取得記錄直接輸出,而不是取得所有記錄後存在記憶體中。
[匯入]
mysql -u userid -p [-h localhost] db_Name < xxxxx.sql
[匯出後立即匯入到另一台主機]
mysqldump -u [SOURCE_userid] -h [SOURCE_IP] -e -q --password=[SOURCE_PASSWORD] SOURCE_db_Name | mysql -u [DISTANCE_userid] --password=[DISTANCE_PASSWORD] -h [DISTANCE_IP] DISTANCE_db_Name
2008年6月13日 星期五
PHP 下載檔案時, 無法直接開啟文件的解法方法
一般都是用 header 來下載檔案, 如下所示
header("Content-length: ".$row->file_size);
header("Content-Disposition: attachment; filename=".$filename);
print($row->filedata);
但通常必需先儲存後再開啟,
不然會出現錯誤, 因需無法直接開啟文件
若要直接開啟文件
需加幾個語法, 如下所示
ob_start();
header("Cache-Control: cache, must-revalidate");
header("Content-length: ".$row->file_size);
header("Content-Disposition: attachment; filename=".$filename);
print($row->filedata);
ob_flush();
PHP 上傳檔案並寫入MySQL 出現 MySQL server has gone away
你可能得到[MySQL server has gone away]錯誤。
如果mysqld得到一個太大或不正常的packet,它認為客戶出錯了並關閉連接。
所以你需要較大的查詢(例如,如果你正在處理較大的BLOB列)時,
你可以使用 -O max_allowed_packet=#
重新啟動mysqld以增加查詢限制。
需分配多餘的記憶體,這樣mysqld只有在你使用較大差詢時或mysqld必須返回較大的結果行時,才能使用更多的記憶體!
以下為修改方式
打開my.ini 找到[mysqld]這一行,下方添加
[mysqld]
#擴大緩衝區
max_allowed_packet=16M
SAVE後,重啟mysql
2008年1月13日 星期日
linux 使用 wake on lan
可以試建立
/etc/init.d/halt.local
~~~內容如下
# script with local commands to be executed from init on system shutdown
#
# Here you should add things, that should happen directly before shuting
# down.
#
# enable WOL for magic packet (g) and broadcast (b)
#wol pumbagsd...
# Set Wake-on-LAN options. Not all devices support this. The
# argument to this option is a string of characters specifying
# which options to enable.
# p Wake on phy activity
# u Wake on unicast messages
# m Wake on multicast messages
# b Wake on broadcast messages
# a Wake on ARP
# g Wake on MagicPacket(tm)
# s Enable SecureOn(tm) password for MagicPacket(tm)
# d Disable (wake on nothing). This option clears all previous
# options.
/sbin/ifup eth0
/usr/sbin/ethtool -s eth0 wol g
#/usr/sbin/ethtool eth0
沒有ethtool 要先安裝 ethtool 套件:
apt-get install ethtool
執行 ethtool:
$ ethtool eth0
Settings for eth0:
Supports Wake-on: g
Wake-on: d
Link detected: yes
主要要看 Wake-on 這一項,要設成 g:
$ ethtool -s eth0 wol g
在執行一次 ethtool 確認有設定好:
$ ethtool eth0
Settings for eth0:
Supports Wake-on: g
Wake-on: g
Link detected: yes
由於這是在電腦開機前動作,
被喚醒的電腦只需要有 BIOS 及硬體有支援即可!
這樣就 ok 了。