Tumgik
dlrlals · 8 years
Text
windows10 bash 에 ruby 2.31 인스톨하기
선행작업
sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
인스톨
cd git clone https://github.com/rbenv/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL rbenv install 2.3.1 rbenv global 2.3.1 ruby -v
0 notes
dlrlals · 10 years
Text
Dokku로 Private PaaS 구축하기
서버에 Dokku를 깔았다. 전부터 Private PaaS를 구축하고 싶었기에 봐뒀던것이 DEIS인데 이녀석은 CoreOS라는 녀석이 Host에 깔려 있어야 한다. 내 서버는 우분투 14.04. MacMiniVault 에서는 다른 OS설치 옵션으로 Core OS는 지원하지 않는다. 그래서 고민하던 차에 알게된게 Dokku.
이녀석은 스케일 업,스케일 아웃 등은 지원하지 않는다.어짜피 서버 한대에서만 돌아가니까.
Dokku 프로젝트 주소
https://github.com/progrium/dokku
문서
http://progrium.viewdocs.io/dokku/index
설치환경은 깡통 우분트 14.04에서 도커만 깔려있는 상태였다.
설치는 명령줄 한줄로 가능하다. 혹시나 한번에 되지 않으면 다시 한번 실행시켜 주면 된다.
wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash
나는 아래처럼 종료되서 "apt-get install -qq -y python-software-properties" 를 한번 실행시켜 주고 다시 설치 스크립트를 실행했더니 설치 되었다.
Reading package lists... Done [[ $(lsb_release -sr) == "12.04" ]] && apt-get install -qq -y python-software-properties cd ~ test -d dokku || git clone $DOKKU_REPO cd dokku git fetch origin if [[ -n $DOKKU_BRANCH ]]; then git checkout origin/$DOKKU_BRANCH elif [[ -n $DOKKU_TAG ]]; then git checkout $DOKKU_TAG fi make install echo echo "Almost done! For next steps on configuration:" echo " http://progrium.viewdocs.io/dokku/installation#user-content-configuring" Selecting previously unselected package help2man. (Reading database ... 175253 files and directories currently installed.) Preparing to unpack .../help2man_1.44.1_amd64.deb ... Unpacking help2man (1.44.1) ... Selecting previously unselected package make. Preparing to unpack .../make_3.81-8.2ubuntu3_amd64.deb ... Unpacking make (3.81-8.2ubuntu3) ... Processing triggers for install-info (5.2.0.dfsg.1-2) ... Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Setting up help2man (1.44.1) ... Setting up make (3.81-8.2ubuntu3) ... account@devbox:~$ dokku version dokku: command not found
account@devbox:~$ sudo apt-get install -qq -y python-software-properties Selecting previously unselected package python-pycurl. (Reading database ... 175304 files and directories currently installed.) Preparing to unpack .../python-pycurl_7.19.3-0ubuntu3_amd64.deb ... Unpacking python-pycurl (7.19.3-0ubuntu3) ... Selecting previously unselected package python-software-properties. Preparing to unpack .../python-software-properties_0.92.37.3_all.deb ... Unpacking python-software-properties (0.92.37.3) ... Setting up python-pycurl (7.19.3-0ubuntu3) ... Setting up python-software-properties (0.92.37.3) ... account@devbox:~$ wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash Ign http://security.ubuntu.com trusty-security InRelease Hit http://security.ubuntu.com trusty-security Release.gpg Ign http://us.archive.ubuntu.com trusty InRelease Hit http://security.ubuntu.com trusty-security Release . . . etting up libxslt1.1:amd64 (1.1.28-2build1) ... Setting up nginx-common (1.6.2-5+trusty0) ... Processing triggers for ureadahead (0.100.0-16) ... Processing triggers for ufw (0.34~rc-0ubuntu2) ... Setting up nginx-full (1.6.2-5+trusty0) ... Setting up nginx (1.6.2-5+trusty0) ... Processing triggers for libc-bin (2.19-0ubuntu6.5) ... dokku plugins-install git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~master (2015-02-21T22:50+0000)' > ~dokku/VERSION account@devbox:~$ dokku version v0.3.15
이제 문제가 개발컴(노트북) 에서 서버로 git push 를 날리면 도쿠가 인식하도록 해줘야 하는 작업이 있는데 이게 되려면 개발컴에서 서버로 ssh로 접속할때 쓰는 서버 계정이 sudo명령어를 실행했을시 패스워드를 묻지 않아야 한다. ssh 로 root 연결이 가능하면 그렇게 해도 되긴하지만 보통 연결하는 서버 계정에 SU 패스워드를 물어보지 않도록 작업하는게 깔끔할듯.
서버에 /etc/sudoers 파일을 열어서 아래 한줄을 추가해준다.
사용자명 ALL=NOPASSWD: ALL
그리고 개발컴에서 다음을 실행해준다. 물론 개발컴 계정에서 공개키가 있어야 한다. 완료되면 다음줄처럼 :으로 구분되는 문자열이 출력된다.
$ cat ~/.ssh/id_rsa.pub | ssh 서버주소 "sudo sshcommand acl-add dokku 계정이름" 45:49:d1:f4:xx:xx:xx:xx:xx:xx:xx:xx:c5:4d:3a:61
이제 설치가 끝났다. heroku용 node.js 샘플을 올려서 테스트 해보자.
localhost:dokku_sample account$ git clone https://github.com/heroku/node-js-sample.git Cloning into 'node-js-sample'... remote: Counting objects: 378, done. remote: Compressing objects: 100% (307/307), done. remote: Total 378 (delta 42), reused 378 (delta 42) Receiving objects: 100% (378/378), 211.25 KiB | 174.00 KiB/s, done. Resolving deltas: 100% (42/42), done. Checking connectivity... done. localhost:dokku_sample account$ cd node-js-sample/ localhost:node-js-sample account$ git remote add dokku dokku@서버주소:node_test localhost:node-js-sample account$ git push dokku master Counting objects: 378, done. Delta compression using up to 2 threads. Compressing objects: 100% (307/307), done. Writing objects: 100% (378/378), 211.25 KiB | 0 bytes/s, done. Total 378 (delta 42), reused 378 (delta 42) -----> Cleaning up... -----> Building node_test from buildstep... -----> Adding BUILD_ENV to build environment... -----> Node.js app detected -----> Requested node range: 0.10.x -----> Resolved node version: 0.10.36 -----> Downloading and installing node -----> Exporting config vars to environment -----> Installing dependencies [email protected] node_modules/express ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ([email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected], [email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected]) └── [email protected] ([email protected], [email protected]) -----> Caching node_modules directory for future builds -----> Cleaning up node-gyp and npm artifacts -----> No Procfile found; Adding npm start to new Procfile -----> Building runtime environment -----> Discovering process types Procfile declares types -> web -----> Releasing node_test... -----> Deploying node_test... -----> Running pre-flight checks check-deploy: /home/dokku/node_test/CHECKS not found. attempting to retrieve it from container ... CHECKS file not found in container. skipping checks. -----> Running post-deploy -----> Creating new /home/dokku/node_test/VHOST... -----> Configuring node_test.devbox.so... -----> Creating http nginx.conf -----> Running nginx-pre-reload Reloading nginx =====> Application deployed: http://node_test.서버주소 To dokku@서버주소:node_test * [new branch] master -> master localhost:node-js-sample account$
0 notes
dlrlals · 10 years
Text
osx 에서 ruby 업그레이드
osx에서 ruby를 제대로 쓰려면 업그레이드를 해야한다. 요세미티도 마찬가지이다.
현재 요세미티 기본 설치후 루비버전은 2.0 이다. 업그레이드 하면 2.1.3 이된다.
업그레이드 자체는 무척 쉽다. sudo su - 로 root로 변환후 아래 명령어를 입력하면 된다.
devbox:~ root# \curl -sSL https://get.rvm.io | bash -s stable --ruby
그리고 ram use 로 버전을 지정해준다.
devbox:~ root# rvm use ruby-2.1.3
0 notes
dlrlals · 10 years
Text
mariadb install with homebrew
install
devbox:~ administrator$ brew install mariadb ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mariadb-10.0.13.mavericks.bottle.tar.gz Already downloaded: /Library/Caches/Homebrew/mariadb-10.0.13.mavericks.bottle.tar.gz ==> Pouring mariadb-10.0.13.mavericks.bottle.tar.gz ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. To connect: mysql -uroot To have launchd start mariadb at login: ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents Then to load mariadb now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist Or, if you don't want/need launchctl, you can just run: mysql.server start ==> /usr/local/Cellar/mariadb/10.0.13/bin/mysql_install_db --verbose --user=administrator --basedir=/usr/local/Cellar/mariadb/10.0.13 --datadir=/usr/local/var/mysql --tmpdir=/tmp ==> Summary 🍺 /usr/local/Cellar/mariadb/10.0.13: 524 files, 125M
security install
devbox:~ administrator$ mysql_secure_installation /usr/local/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): 이부분에서 처음 설치인경우 패스워드가 없으므로 그냥 엔터를 친다. OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
0 notes
dlrlals · 10 years
Text
osx에서 bash bug 패치하기
bash , sh 컴파일 및 인스톨
$ mkdir bash-fix $ cd bash-fix $ curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf - $ cd bash-92/bash-3.2 $ curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0 $ curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-053 | patch -p0 $ cd .. $ xcodebuild $ sudo cp /bin/bash /bin/bash.old $ sudo cp /bin/sh /bin/sh.old $ build/Release/bash --version # GNU bash, version 3.2.53(1)-release $ build/Release/sh --version # GNU bash, version 3.2.53(1)-release $ sudo cp build/Release/bash /bin $ sudo cp build/Release/sh /bin
취약점 테스트
$ env x='() { :;}; echo vulnerable' bash -c 'echo hello' bash: warning: x: ignoring function definition attempt bash: error importing function definition for `x' hello
새로운 취약점 테스트
$ env X='() { (a)=>\' sh -c "echo date"; cat echo sh: X: line 1: syntax error near unexpected token `=' sh: X: line 1: `' sh: error importing function definition for `X' Thu 25 Sep 2014 08:54:13 BST
기존 bash , sh 삭제 , 리부팅
$ sudo rm /bin/bash.old /bin/sh.old $ sudo reboot
0 notes
dlrlals · 10 years
Text
swift regular expression
swift로 정규식 사용하기. 근데 좀더 간단한 방법이 있음 좋겠다.
import Foundation // definition substring extension String { subscript (r: Range) -> String { get { let subStart = advance(self.startIndex, r.startIndex, self.endIndex) let subEnd = advance(subStart, r.endIndex - r.startIndex, self.endIndex) return self.substringWithRange(Range(start: subStart, end: subEnd)) } } func substring(from: Int) -> String { let end = countElements(self) return self[from..end] } func substring(from: Int, length: Int) -> String { let end = from + length return self[from..end] } func substring(range: Range ) -> String { let end = range.endIndex return self[range.startIndex..end] } } // regexp test println("swift regexp test") var sampleString = "ABCDEFG" var regexp = NSRegularExpression(pattern: "AB(.+)FG", options: nil, error: nil) var match = regexp.firstMatchInString(sampleString,options:nil,range:NSMakeRange(0,countElements(sampleString))) println( "sample string is " + sampleString) println( "count of math : \( match.numberOfRanges )" ) println(match.rangeAtIndex(0)) println(match.rangeAtIndex(1)) println(sampleString.substring(match.rangeAtIndex(0))) println(sampleString.substring(match.rangeAtIndex(1)))
substring 부분은 아래 url참고해서 작성함.
http://stackoverflow.com/questions/24044851/how-do-you-use-string-substringwithrange-or-how-do-ranges-work-in-swift
0 notes
dlrlals · 11 years
Text
ubuntu server 12.04.4 LTS LDAP Install
hosts 파일을 편집해준다.
sudo vi /etc/hosts/
127.0.0.1 localhost 127.0.1.1 ryuhonlinux.example.com ryuhonLinux
설치
sudo apt-get install slapd ldap-utils
설정
sudo dpkg-reconfigure slapd
0 notes
dlrlals · 11 years
Text
osx에서 installer로 설치한 postgresql 삭제방법
삭제 스크립스 실행
sudo /Library/PostgreSQL/9.1/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh
디렉토리 삭제
sudo rm -rf /Library/PostgreSQL
ini파일 삭제
sudo rm /etc/postgres-reg.ini
postgresql 계정 삭제
shared memory setting 복구
sudo rm /etc/sysctl.conf
0 notes
dlrlals · 11 years
Text
인텔리j에서 spring + mybatis 조합에서 mapper.xml 찾지못해 오류일때
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [com/domain/sql/mapper/UserDao.xml]'; nested exception is java.io.FileNotFoundException: class path resource [com/domain/sql/mapper/UserDao.xml] cannot be opened because it does not exist
이런 에러가날때가 있다.
mybatis 설정 xml파일을 보면
<property name="mapperLocations" value="classpath:com/domain/sql/mapper/*.xml" />
이런식으로 되어있을텐데
<property name="mapperLocations" value="classpath*:com/domain/sql/mapper/*.xml" />
으로 바꿔주면 된다.
classpath뒤에 * 붙여주면 해결.
1 note · View note
dlrlals · 11 years
Text
Install nginx in osx with homebrew
homebrew 설치 (없다면)
~# ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
nginx 설치: 
~# brew install nginx
nginx 실행:
~# sudo nginx
테스트:
http://localhost:8080
nginx 설정:
~# sudo vi /usr/local/etc/nginx/nginx.conf
0 notes
dlrlals · 11 years
Text
osx의 vim Syntax Highlighting
$ sudo vi /usr/share/vim/vimrc
" add for next lines set tabstop=4 set ai " auto indenting set history=100 " keep 100 lines of history set ruler " show the cursor position syntax on " syntax highlighting set hlsearch " highlight the last searched term filetype plugin on " use the file type plugins " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if ! exists("g:leave_my_cursor_position_alone") | \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal g'\"" | \ endif | \ endif
0 notes
dlrlals · 11 years
Text
안드로이드 설정값 저장
값 불러오기
SharedPreferences pref = getSharedPreferences("설정이름", MODE_PRIVATE); pref.getString("키", "");
값 저장하기
SharedPreferences pref = getSharedPreferences("설정이름", MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putString("key", "value"); editor.commit();
값 저장하기
SharedPreferences pref = getSharedPreferences("설정이름", MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.remove("key"); editor.commit()
전체 삭제하기
SharedPreferences pref = getSharedPreferences("설정이름", MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.clear(); editor.commit()
0 notes