본문 바로가기
  • 경제적 자유를 얻는 그날까지
엔지니어링/프로그래밍

Github.io 블로그 만들기(2) - Local 서버 설정

by 베니스상인 2023. 1. 26.

 

 

 

블로그 생성하기 내용은 아래 게시글 참고

 

https://swiftcam.tistory.com/647

 

Github.io 블로그 만들기(1) - 생성하기

1. Github에서 새로운 Repository 생성하기 repository name에 반드시 username.github.io로 새로운 repository를 만들어주어야 한다. Create repository 하면 아래와 같이 메인 페이지가 보이는 repository가 생성된다. 2. L

swiftcam.tistory.com

 

 

 

생성된 블로그를 꾸미는 방법 시작~!

 

 

 

1. jekyll 및 기타 프로그램 설치

  • 설치하기전 기존의 github.io에 있던 README.md과 index.html 파일은 모두 삭제한다.
  • 터미널을 열고 아래 명령어로 jekyll을 설치한다.
  • bundle install에서 패스워드를 물어보면 root 계정의 패스워드를 입력하면 된다.
  • jekyll 실행시 bundler의 버전이 낮아서 중단되면 gem install로 해당버전으로 업데이트한다.

$ sudo apt-get install jekyll bundler

$ jekyll new ./

$ sudo bundle install

$ sudo gem install bundler:2.1.4

 

 

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ ll
total 20
drwxrwxr-x 3 swift swift 4096  1월 26 14:26 ./
drwxrwxr-x 3 swift swift 4096  1월 26 14:19 ../
drwxrwxr-x 8 swift swift 4096  1월 26 14:34 .git/
-rw-rw-r-- 1 swift swift   12  1월 26 14:26 index.html
-rw-rw-r-- 1 swift swift   20  1월 26 14:19 README.md

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ rm -rf index.html 
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ rm README.md 

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ sudo apt-get install jekyll bundler
[sudo] password for swift: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libgdbm5 linux-generic linux-headers-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libgmp-dev libgmpxx4ldbl libhttp-parser2.9 python-chardet
  python-pkg-resources python-pygments ruby-addressable ruby-afm ruby-ascii85
  ruby-blankslate ruby-bundler ruby-classifier-reborn ruby-coderay
  ruby-colorator ruby-concurrent ruby-dev ruby-em-websocket ruby-eventmachine
  ruby-fast-stemmer ruby-ffi ruby-forwardable-extended ruby-hashery
  ruby-http-parser.rb ruby-i18n ruby-jekyll-sass-converter ruby-jekyll-watch
  ruby-kramdown ruby-launchy-shim ruby-liquid ruby-listen ruby-mercenary
  ruby-mime-types ruby-mime-types-data ruby-molinillo ruby-multi-json
  ruby-net-http-persistent ruby-oj ruby-parslet ruby-pathutil ruby-pdf-core
  ruby-pdf-reader ruby-posix-spawn ruby-prawn ruby-prawn-table
  ruby-public-suffix ruby-pygments.rb ruby-rb-inotify ruby-rc4 ruby-rdiscount
  ruby-redcarpet ruby-rouge ruby-safe-yaml ruby-sass ruby-stringex ruby-thor
  ruby-toml ruby-ttfunk ruby-yajl ruby2.7-dev ruby2.7-doc
Suggested packages:
  ruby-jekyll-coffeescript ruby-jekyll-compose ruby-jekyll-feed
  ruby-jekyll-gist ruby-jekyll-last-modified-at ruby-jekyll-paginate
  | ruby-jekyll-paginate-v2 ruby-jekyll-redirect-from ruby-jekyll-remote-theme
  ruby-jekyll-seo-tag ruby-jekyll-sitemap gmp-doc libgmp10-doc libmpfr-dev
  python-setuptools python-pygments-doc ttf-bitstream-vera
  ruby-http-parser.rb-doc libjs-mathjax ruby-activesupport coderay
  fonts-arphic-gkai00mp ruby-pdf-inspector ruby-prawn-doc ruby-sass-listen
  ttf-dejavu-core
The following NEW packages will be installed:
  bundler jekyll libgmp-dev libgmpxx4ldbl libhttp-parser2.9 python-chardet
  python-pkg-resources python-pygments ruby-addressable ruby-afm ruby-ascii85
  ruby-blankslate ruby-bundler ruby-classifier-reborn ruby-coderay
  ruby-colorator ruby-concurrent ruby-dev ruby-em-websocket ruby-eventmachine
  ruby-fast-stemmer ruby-ffi ruby-forwardable-extended ruby-hashery
  ruby-http-parser.rb ruby-i18n ruby-jekyll-sass-converter ruby-jekyll-watch
  ruby-kramdown ruby-launchy-shim ruby-liquid ruby-listen ruby-mercenary
  ruby-mime-types ruby-mime-types-data ruby-molinillo ruby-multi-json
  ruby-net-http-persistent ruby-oj ruby-parslet ruby-pathutil ruby-pdf-core
  ruby-pdf-reader ruby-posix-spawn ruby-prawn ruby-prawn-table
  ruby-public-suffix ruby-pygments.rb ruby-rb-inotify ruby-rc4 ruby-rdiscount
  ruby-redcarpet ruby-rouge ruby-safe-yaml ruby-sass ruby-stringex ruby-thor
  ruby-toml ruby-ttfunk ruby-yajl ruby2.7-dev ruby2.7-doc
0 upgraded, 62 newly installed, 0 to remove and 33 not upgraded.
Need to get 7,354 kB of archives.
After this operation, 48.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://kr.archive.ubuntu.com/ubuntu focal/universe amd64 ruby-molinillo all 0.6.4-1 [19.8 kB]


swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Following files may not be writable, so sudo is needed:
  /usr/local/bin
  /var/lib/gems/2.7.0
Fetching public_suffix 5.0.1


Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle install --path vendor/bundle

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 
  
Installing public_suffix 5.0.1
Fetching addressable 2.8.1
Installing addressable 2.8.1
Using bundler 2.1.4
Using colorator 1.1.0
Fetching concurrent-ruby 1.2.0
Installing concurrent-ruby 1.2.0
Fetching eventmachine 1.2.7
Installing eventmachine 1.2.7 with native extensions
Fetching http_parser.rb 0.8.0
Installing http_parser.rb 0.8.0 with native extensions
Fetching em-websocket 0.5.3
Installing em-websocket 0.5.3
Fetching ffi 1.15.5
Installing ffi 1.15.5 with native extensions
Using forwardable-extended 2.6.0
Fetching i18n 0.9.5
Installing i18n 0.9.5
Using sass 3.7.4
Using jekyll-sass-converter 1.5.2
Fetching rb-fsevent 0.11.2
Installing rb-fsevent 0.11.2
Fetching rb-inotify 0.10.1
Installing rb-inotify 0.10.1
Fetching listen 3.8.0
Installing listen 3.8.0
Using jekyll-watch 2.2.1
Using kramdown 1.17.0
Fetching liquid 4.0.4
Installing liquid 4.0.4
Using mercenary 0.3.6
Fetching pathutil 0.16.2
Installing pathutil 0.16.2
Fetching rouge 3.30.0
Installing rouge 3.30.0
Using safe_yaml 1.0.5
Fetching jekyll 3.8.7
Installing jekyll 3.8.7
Fetching jekyll-feed 0.17.0
Installing jekyll-feed 0.17.0
Fetching jekyll-seo-tag 2.8.0
Installing jekyll-seo-tag 2.8.0
Fetching minima 2.5.1
Installing minima 2.5.1
Bundle complete! 6 Gemfile dependencies, 27 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

 

 

 

2. bundle 서버 실행

  • bundle 명령어를 사용하여 jekyll을 Local 서버에 뛰운다.

$ bundle exec jekyll serve

 

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ bundle exec jekyll serve
/var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/drops/document_drop.rb:8: warning: already initialized constant Jekyll::Drops::DocumentDrop::NESTED_OBJECT_FIELD_BLACKLIST
/usr/lib/ruby/vendor_ruby/jekyll/drops/document_drop.rb:8: warning: previous definition of NESTED_OBJECT_FIELD_BLACKLIST was here
/var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/drops/drop.rb:8: warning: already initialized constant Jekyll::Drops::Drop::NON_CONTENT_METHODS
/usr/lib/ruby/vendor_ruby/jekyll/drops/drop.rb:8: warning: previous definition of NON_CONTENT_METHODS was here
Configuration file: /home/swift/workspace/git/shlee853.github.io/_config.yml
            Source: /home/swift/workspace/git/shlee853.github.io
       Destination: /home/swift/workspace/git/shlee853.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/document.rb:449: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
/usr/lib/ruby/vendor_ruby/jekyll/convertible.rb:41: warning: Using the last argument as keyword parameters is deprecated
       Jekyll Feed: Generating feed for posts
                    done in 0.551 seconds.
/var/lib/gems/2.7.0/gems/pathutil-0.16.2/lib/pathutil.rb:502: warning: Using the last argument as keyword parameters is deprecated
 Auto-regeneration: enabled for '/home/swift/workspace/git/shlee853.github.io'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

 

 

 

 

 

서버가 실행되면 아래 메시지처럼 Server address: http://127.0.0.1:4000/ 가 나타나고 주소창에 로컬 서버 주소를 입력하면 홈페이지가 나타난다.

 

 

 

 

3. jekyll 내용을 Remote로 업로드

  • 기존의 index.html 내용을 Local 서버의 내용으로 업로드하기 위해 Remote로 pull 해준다.

$ git add .

$ git status

$ git commit -m "Replace contents with jekyll local server"

 

 

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ git add .

swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   .sass-cache/448bc18ff01dcabd446f01465c58a3dc3061895e/minima.scssc
	new file:   .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_base.scssc
	new file:   .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_layout.scssc
	new file:   .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_syntax-highlighting.scssc
	new file:   404.html
	new file:   Gemfile
	new file:   Gemfile.lock
	deleted:    README.md
	new file:   _config.yml
	new file:   _posts/2023-01-26-welcome-to-jekyll.markdown
	new file:   _site/404.html
	new file:   _site/about/index.html
	new file:   _site/assets/main.css
	new file:   _site/assets/minima-social-icons.svg
	new file:   _site/feed.xml
	new file:   _site/index.html
	new file:   _site/jekyll/update/2023/01/26/welcome-to-jekyll.html
	new file:   about.md
	deleted:    index.html
	new file:   index.md


swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ git commit -m "Replace contents with jekyll local server"
[main c5faa51] Replace contents with jekyll local server
 20 files changed, 1124 insertions(+), 2 deletions(-)
 create mode 100644 .sass-cache/448bc18ff01dcabd446f01465c58a3dc3061895e/minima.scssc
 create mode 100644 .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_base.scssc
 create mode 100644 .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_layout.scssc
 create mode 100644 .sass-cache/64b43ec21ceaf9e7ce723322abfe585642e724bf/_syntax-highlighting.scssc
 create mode 100644 404.html
 create mode 100644 Gemfile
 create mode 100644 Gemfile.lock
 delete mode 100644 README.md
 create mode 100644 _config.yml
 create mode 100644 _posts/2023-01-26-welcome-to-jekyll.markdown
 create mode 100644 _site/404.html
 create mode 100644 _site/about/index.html
 create mode 100644 _site/assets/main.css
 create mode 100644 _site/assets/minima-social-icons.svg
 create mode 100644 _site/feed.xml
 create mode 100644 _site/index.html
 create mode 100644 _site/jekyll/update/2023/01/26/welcome-to-jekyll.html
 create mode 100644 about.md
 delete mode 100644 index.html
 create mode 100644 index.md


swift@swift-HP-Pavilion-dv6-Notebook-PC:~/workspace/git/shlee853.github.io$ git push
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 8 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (32/32), 43.49 KiB | 2.90 MiB/s, done.
Total 32 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To https://github.com/shlee853/shlee853.github.io.git
   4c3f31d..c5faa51  main -> main

 

 

 

Remote에 정상적으로 업로드되었다면, username.github.io로 접속해도 local server의 내용으로 그대로 나타나야 한다. 

브라우저에서 새로 창을 열고 주소를 입력하면 아래와 같이 Local server의 내용이 나타난다.

 

 

728x90

댓글