廣告

顯示具有 ubuntu 標籤的文章。 顯示所有文章
顯示具有 ubuntu 標籤的文章。 顯示所有文章

2016年7月13日 星期三

2016年3月10日 星期四

Apache_httpd_to_Tomcat-Mod_Proxy_Setup.txt | 轉址


sudo vi /opt/lampp/etc/httpd.conf

Make sure the following are uncommented:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Add these:
ProxyPass         /eInvoiceLocate http://localhost:8080/eInvoiceLocate
ProxyPassReverse  /eInvoiceLocate http://localhost:8080/eInvoiceLocate

Reload Apache conf
# cd /opt/lampp/bin
# sudo ./apachectl -k graceful


2016年2月25日 星期四

apache xmlhttprequest cannot load origin is not allowed by access-control-allow-origin |ajax 跨網頁存取圖片遇到cors

修改這個檔:
/opt/lampp/etc/httpd.conf

在 <Directory "/opt/lampp/htdocs"> 區段加入:
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "x-requested-with"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"

重起
sudo /opt/lampp/bin/apachectl -k graceful

關於cors

2015年7月24日 星期五

[linux] how to get log of rc.local


add below script to your /etc/rc.local

exec 2> /tmp/rc.local.log  # send stderr from rc.local to a log file
exec 1>&2                  # send stdout to the same log file
set -x                     # tell sh to display commands before execution


2015年6月18日 星期四

putty connect with ppk auth


1. 下載putty instatller
2. 開啟pageant.exe 加入PPK檔  
3. 接著用putty就能連上了

2015年5月26日 星期二

[linux] crontab 命令裡面 % 的意思是斷行


今天設計了新的java參數讓cronjob跑,
發現cronjob沒有再跑,

後來上網查了發現 是 % 這個符號的關係,
這符號的意思是換行,所以這符號後面的參數我的jar檔就吃不到啦~

引用

A <percent-sign> character in this field shall be translated 
to a <newline<. Any character preceded by a <backslash> (including the '%' ) 
shall cause that character to be treated literally. Only the first 
line (up to a '%' or end-of-line) of the command field shall be 
executed by the command interpreter. The other lines shall 
be made available to the command as standard input. 


2015年4月30日 星期四

[linux] [java] download jdk1.7 64bit on linux and add to environment path



download jdk1.7 64bit for linux 

這樣是不行的
wget http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.tar.gz" \
-O jdk-7-linux-x64.tar.gz


要加header
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.tar.gz" \
-O jdk-7-linux-x64.tar.gz


因為下載頁面有一個需要點選接受的按鈕.


解壓縮:
tar -xzf jdk-7-linux-x64.tar.gz -C /opt/

新增環境變數
export PATH=$PATH:/opt/jdk1.7.0_55/bin

export JAVA_HOME=/opt/jdk1.7.0_55/

2015年4月27日 星期一

[linux][解決] xampp 裝完後發現連不到他的mysql


法一
發現連不到資料庫
http://192.168.22.148/phpmyadmin/


做以下步驟:
cd到/opt/lampp/phpmyadmin

修改內容config.inc.php
$ sudo vim config.inc.php
$ cfg['Servers'][$i]['password']='your password'


進入mysql command line
$ /opt/lampp/bin/mysql -u root -plewis

更新密碼
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';


重啟
$ sudo /opt/lampp/lampp start
$ sudo /opt/lampp/lampp stop


法二
或者是在xampp安裝完時

輸入以下指令
sudo /opt/lampp/lampp security

2015年4月26日 星期日

[linux] install xampp on ubuntu


以下為錯誤步驟 , 可以跳到下面的正確步驟
step1
add ppa
$ sudo add-apt-repository ppa:upubuntu-com/xampp

此時系統會問你要步要加入ppa
到這網址查看內容https://launchpad.net/~upubuntu-com/+archive/ubuntu/xampp
裡面列出一些package
ppa : Personal Package Archive
詳細參考http://article.yeeyan.org/view/213582/193672


step2
$ sudo apt-get update

step3
$ sudo apt-get install xampp

此方法不行因為缺少套件
所以先移除吧
$ sudo apt-get remove xampp
ppa也別忘了移除
$  sudo add-apt-repository --remove ppa:upubuntu-com/xampp



以下為正確步驟
好的我們重來一次

#下載xampp包到指定路徑
$ wget -P /opt/download/xampp64bit.run http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.8.3/xampp-linux-x64-1.8.3-2-installer.run/download

#添加權限
$ sudo chmod +x xampp64bit.run

#執行
$ sudo ./xampp64bit.run


#接著會進入安裝畫面,就下一步下一步吧

#啟動 lampp
$ sudo /opt/lampp/lampp start

#看到以下訊息
Starting XAMPP for Linux 1.8.3-2...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.


如果要啟動VM就自行運作 xampp
$ sudo vim /etc/rc.local
加入
/opt/lampp/lampp start
exit 0

將網頁放到如下位置即可呈現
/opt/lampp/htdocs/

因為我是用putty連到我的vm
所以測試成功與否就從外部的window來看
結果如下:













xampp 帳/密 xampp/lewis
mysql 障/密 root/lewis
連不到sql的話參考這篇
workbench連不到參考這篇

[linux] Install tomcat7.0.61 on ubuntu with "wget"

安裝tomcat

這邊用wget而不用apt-get install
因為用後者會把一些內容放到不同目錄
這樣不好管理,當然每個人習慣不同.
#下載apache-tomcat-7.0.61.tar.gz
$ wget http://ftp.tc.edu.tw/pub/Apache/tomcat/tomcat-7/v7.0.61/bin/apache-tomcat-7.0.61.tar.gz


#解壓縮到/opt/  ,opt/:一般都是放第三方服務的安裝
$ sudo tar -xzf apache-tomcat-7.0.61.tar.gz -C /opt/


#啟動tomcat
$ sudo sh /opt/apache-tomcat-7.0.61/bin/startup.sh
#會看到如下訊息
Using CATALINA_BASE:   /opt/apache-tomcat-7.0.61
Using CATALINA_HOME:   /opt/apache-tomcat-7.0.61
Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.61/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-7.0.61/bin/bootstrap.jar:/opt/apache-tomcat-7.0.61/bin/tomcat-juli.jar
Tomcat started.


因為我是用putty 連到我的vm
所以測試成功與否就從外部的window來看
結果如下

#接著要修改使用者帳密
$ sudo vim conf/tomcat-users.xml


   
   


改完就可以管理你的app


#重新啟動
$ sudo sh /opt/apache-tomcat-7.0.61/bin/shutdown.sh
$ sudo sh /opt/apache-tomcat-7.0.61/bin/startup.sh














之前有介紹window版本的安裝以及webservice

[linux] remove install app


$ sudo apt-get remove app-name

ex: sudo apt-get remove tomcat7

2015年4月24日 星期五

[linux] crontab 基本使用

這篇主要目的是要說
cronjob執行jar檔 需要給jdk路徑==
WTF
因為看到這篇
http://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work
有時間看一下這篇
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/
詳細教學可以操考下面兩個網址
https://help.ubuntu.com/community/CronHowto
http://linux.vbird.org/linux_basic/0430cron.php

環境變數可以參考這篇


crontab 設定

edit cronjob 
$ crontab -e

list cronjob 
$ crontab -l

例如
* 19-22 * * * cd /opt/acer/cronjob/channelData;export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin; java -cp "./*:./lib/*" com.acer.control.ChnelDataFlowHandler ibobar y y 3 y y y twn 0 ""

restart cron
$ sudo /etc/init.d/cron restart

check log
$ cat /var/log/syslog

[linux] export ,設定環境變數 |Environment variable


#列出目前所有變數
export

#添加變數
export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin

此時打一次exoprt 會發現已經添加

#修改profile
vim /ext/profile
#加入
export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin

#修改.bashrc
cd ~
vim .bashrc
export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin

立即生效:
. ~/.bashrc

#測試
echo $PATH

2015年4月23日 星期四

[linux] vim 常用指令 |vim common command

用putty連linux時,常要改一些設定檔,crronjob, shell script等等
用vim來改比較快也比較方便.

這邊列出一些常用指令


#首先創建一個文字檔
vim filename.txt

#進入編輯模式
i

#離開編輯模式 
esc

#離開
shift + :
q

#離開並存檔
wq

#下列為一般模式下

#左下上右
hjkl

#進階 一次往下5行
5j

#螢幕向下/上 一頁
ctrl + f/b

#移到該行最前面 
0

#尋找
/keyword

#刪除整列
dd

#複製
yy

#貼上 
p

#復原
u


2015年4月21日 星期二

[ununtu] change time-zone settings from the command line


sudo dpkg-reconfigure tzdata

[linux] 將指令的內容輸出到某檔案


use ">"
date +%Y%m%d > backcronjob.txt
lewis@ubuntu:/opt$ cat backcronjob.txt
20150318

lewis@ubuntu:/opt$ ls -l /opt/app/abStore_data/ > backcronjob.txt
lewis@ubuntu:/opt$ cat backcronjob.txt
total 4
drwxr-xr-x 4 root root 4096 Mar 18 13:14 data

2015年4月20日 星期一

[linux] Run jar on linux with command line


here is java test code
package testJava;

public class testLinuxArg {

 public static void main(String[] args) {

  System.out.println("args lenght:" + args.length);

  for (int i = 0; i < args.length; i++) {
   System.out.println("args:" + i + " is : " + args[i] + " type   is "
     + args[i].getClass() + "  length is " + args[i].length());
  }
 }
}

export as jar,
put it to your linux

run jar on linux
 java -cp "the lib you need" fileName
 ex: java -cp "./*:./lib/*" testJava.testLinuxArg "1" "" "3" $(pwd)


2015年3月6日 星期五

[ubuntu] Configure Static IP Address on Linux VM in VMware Player


Everytime I use putty to connect VM,
It's ip will be changed.
This situation is very annoying.
So i decide to set static.IP
There are three networking options for virtual
machines running there: Bridged, NAT, Host-Only.
I use NAT in order to coneect web.
see this  BLOG for detail

$ sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5)
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.22.146
  netmask 255.255.255.0
  broadcast 192.168.22.255
  gateway 192.168.22.2
dns-nameservers 192.168.22.2


you need to restart
$ sudo service networking restart


then you will encounter a problem,
lewis@lewis-virtual-machine:~$ sudo service networking restart
stop: Job failed while stopping

let's to check log
lewis@lewis-virtual-machine:~$ sudo  tail -f /var/log/upstart/networking.log
Stopping or restarting the networking job is not supported.
Use ifdown & ifup to reconfigure desired interface.

//it indicate that not supported

So use this to do
$ sudo ifdown eth0 && ifup eth0
$ sudo /etc/init.d/networking restart


ref:

2015年3月4日 星期三

[ubuntu] cp


cp -r getBookList    / /opt/app/abStore/data/Ibobar/getBookList
       來源             目的地

-a  :相當於 -pdr 的意思,至於 pdr 請參考下列說明;(常用)
-d  :若來源檔為連結檔的屬性(link file),則複製連結檔屬性而非檔案本身;
-f  :為強制(force)的意思,若目標檔案已經存在且無法開啟,則移除後再嘗試一次;
-i  :若目標檔(destination)已經存在時,在覆蓋時會先詢問動作的進行(常用)
-l  :進行硬式連結(hard link)的連結檔建立,而非複製檔案本身;
-p  :連同檔案的屬性一起複製過去,而非使用預設屬性(備份常用);
-r  :遞迴持續複製,用於目錄的複製行為;(常用)
-s  :複製成為符號連結檔 (symbolic link),亦即『捷徑』檔案;
-u  :若 destination 比 source 舊才更新 destination

2015年2月24日 星期二

[ubuntu][unfinish] linux grep and , or

http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/


http://linux.vbird.org/linux_basic/0320bash.php