賴晨旭
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Codimd版本控管服務安裝流程 >[name=賴晨旭] [time=Wed, Jul 24, 2019 2:33 AM] ###### Tags: `服務安裝流程`, `Codimd`, `版本控管`, `主機安裝` ## 修改主機名稱(非必要) #### ==如果你使用的是ubuntu18.04必須先更改/etc/cloud/cloud.cfg== ``` sudo vi /etc/cloud/cloud.cfg #找到preserve_hostname: false修改为preserve_hostname: true ``` #### ==ubuntu16.04只需做以下兩點== ##### 到下面兩個位置把==example==改成想要的名稱 ```shell= sudo vi /etc/hostname ``` ![](https://i.imgur.com/cmIQjza.png) ```shell= sudo vi /etc/hosts ``` ![](https://i.imgur.com/7cOKm0W.png) ### ==重新啟動== ```shell= sudo reboot ``` ## 更改apt更新來源 ### ==複製apt source檔案以免更改出錯== ```shell= $ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk ``` ### ==修改source來源== ```shell= $ sudo vi /etc/apt/sources.list ``` ### ==替換 tw.archive.ubuntu.com 修改為 free.nchc.org.tw== ```bash= :1,$s/tw.archive.ubuntu.com/free.nchc.org.tw/g #替换第1行开始到最后一行中每一行所有 well 为 good ``` ### ==儲存離開後,執行更新== ``` $ sudo apt-get update $ sudo apt-get upgrade ``` ## ntp系統校時 ### ==下載ntp== ```shell= $ sudo apt-get install ntp ntpdate ``` ### ==更改/etc/ntp.conf設定,將以下全部註解,將預設註解== ```bash= # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. pool 0.ubuntu.pool.ntp.org iburst pool 1.ubuntu.pool.ntp.org iburst pool 2.ubuntu.pool.ntp.org iburst pool 3.ubuntu.pool.ntp.org iburst # Use Ubuntu's ntp server as a fallback. pool ntp.ubuntu.com ``` ### ==取消下列註解== ```bash= statsdir /var/log/ntpstats/ ``` ### ==然後新增~~下列幾行~~(擇一),下面是新增台灣區ntp伺服器== ```bash= server time.stdtime.gov.tw ``` ### ==新增/etc/crontab內容== ```bash= 0 1 * * * root /usr/sbin/ntpdate time.stdtime.gov.tw && /sbin/hwclock -w #每天凌晨1點自動校時 ``` ## Zabbix-Agent(可先跳過) ### ==下載zabbix安裝包,並且解壓縮== ```shell= wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb dpkg -i zabbix-release_3.4-1+xenial_all.deb ``` ### ==更新apt,並下載 zabbix-agent== ```shell= sudo apt-get update sudo apt-get install zabbix-agent ``` ### ==修改 /etc/zabbix/zabbix_agentd.conf== ```bash= #Server=[zabbix server ip] #Hostname=[Hostname of client system ] Server=10.10.10.16 ListenIP=0.0.0.0 ServerActive=10.10.10.16 Hostname=cmrdbblog ``` ### ==啟動zabbix== ```shell= sudo service zabbix-agent start ``` ### ==查看zabbix狀態== ```shell= sudo service zabbix-agent status ``` ## apache ### ==安裝apache== ```shell= $ sudo apt-get install apache2 ``` ### ==關閉目錄瀏覽== #### 修改/etc/apache2/apache2.conf ```bash= <Directory /var/www/example.com/public_html/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> ``` #### 刪除 Indexes 變成 ```bash= <Directory /var/www/example.com/public_html/> Options FollowSymLinks AllowOverride None Require all granted </Directory> ``` ### ==關閉版本顯示== #### 在/etc/apache2/apache2.conf最下面添加 ```bash= ServerTokens Prod ServerSignature Off ``` ### ==Apache連線人數上限調整== #### 1.修改/etc/apache2/apache2.conf ```bash= #人數調成1000 MaxKeepAliveRequests 1000 ``` #### 2.修改/etc/apache2/mods-enabled/mpm_prefork.conf ![](https://i.imgur.com/UwoSHy6.png) **如果「mods-enabled」這個資料夾中沒有「mpm_prefork.conf」這個檔案,用以下方法解決** ```shell= $ sudo ln -s /etc/apache2/mods-available/mpm_prefork.conf /etc/apache2/mods-enabled/mpm_prefork.conf ``` ### ==重啟apache2== ```shell= $ sudo service apache2 restart ``` ## PHP 5.6.40 ### ==添加PPA== ```bash= $ sudo add-apt-repository ppa:ondrej/php ``` #### Ubuntu16.04已經不支援php5.6,所以需這樣的手動新增ppa ### ==更新 repo== ```bash= $ sudo apt-get update ``` ### ==安裝 PHP 5.6==  ```bash= $ sudo apt-get install php5.6 ``` ### ==若有需要 php-fpm 5.6 ,可執行下列指令安裝== ```bash= $ sudo apt-get install php5.6-fpm ``` ### ==安裝extension== ```bash= $ sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-sqlite ``` ### ==檢查 php 版本== ``` bash= $ php -v ``` #### 如果建置成功,會出現以下訊息 ![](https://i.imgur.com/VewXlhA.png) ## PHP設定檔 ### ==進入設定檔 /etc/php/5.6/apache2/php.ini== ```bash= cd /etc/php/5.6/apache2/php.ini ``` ### ==更改上傳、POST大小為20MB== ```bash upload_max_filesize = 20M post_max_size = 20M ``` ### ==若發現更改沒用再去更改 /etc/php/5.6/fpm/php.ini== #### 更改上傳,post大小為20MB ```bsah upload_max_filesize = 20M post_max_size = 20M ``` ### ==關閉error顯示== ```bash display_errors=Off ``` #### 如果沒有關閉,當php出錯時會噴出錯誤碼,如下 ![](https://i.imgur.com/A3YO33S.png) ### ==設定PHP時區== #### 因為預設時區會是GMT+0,我們是GMT+8,所以要修改 ```bash ;date.timezone = ``` #### 變成Asia/Taipei ```bash date.timezone = "Asia/Taipei" ``` ### ==關閉PHP版本資訊== ```bash expose_php = off ``` ### ==設定HttpOnly (先別做)== ```bash session.cookie_httponly = true ``` ### ==重新啟動== ```shell= $ sudo /etc/init.d/apache2 restart ``` ### ==查看php目錄== #### 在php所做的設定可在/var/www/html底下新增index.php ##### index.php內容如下 ```bash= <?php phpinfo(); ?> ``` #### 開啟瀏覽器輸入ip在後面增加/index.php便可查看是否更改成功 ![](https://i.imgur.com/rFOKqTC.png) #### 檢查完後記得刪除 index.php ### ==安裝phpmyadmin== ```shell= $ sudo apt-get install phpmyadmin ``` ## Mariadb ### ==安裝 Mariadb== ```shell= sudo apt-get install mariadb-server mariadb-client sudo apt install maria ``` ### ==進入Mariadb== ```shell= sudo mysql ``` ### ==創建新數據庫== ```shell mysql> create database codimd; <==注意每個指令後面要加上 ; Query OK, 1 row affected (0.00 sec) ``` ### ==創建新使用者== ```shell mysql> CREATE USER 'codimd'@'localhost' IDENTIFIED BY '密碼'; Query OK, 0 rows affected (0.00 sec) ``` #### 並將剛剛建立的資料庫權限給你宣告的這個帳號! ```shell mysql> grant all privileges on codimd.* to codimd@localhost identified by '密碼' ; Query OK, 0 rows affected (0.01 sec) ``` ### ==更新權限== #### 如果沒做,當你離開資料庫時,權限將會全部復原回更改前 ```shell mysql>flush privileges; ``` ### ==Mariadb上線總人數調整== #### 修改/etc/mysql/mariadb.conf.d/50-server.cnf #### 人數調成1000 ```bash= max_connections = 1000 ``` ### ==重啟mariadb== ```shell= $ sudo service mysql restart ``` ## 安裝必要套件 ```bash= sudo apt-get install curl git npm node-gyp gcc ``` ### ==安裝nodeJS== ```shell= curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - ``` #### (此時可能會出現↓) ![](https://i.imgur.com/AnyTctL.png) #### 照著跑一輪即可 ```shell= sudo apt-get install -y nodejs sudo apt-get install gcc g++ make ``` ### ==安裝yarn== ```shell= curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn ``` ## CodiMD安裝與設定 ### ==clone CodiMD git== #### (請cd至根目錄底下的opt) ```shell= cd /opt sudo git clone https://github.com/hackmdio/codimd.git ``` ### ==安裝 CodiMD== #### 建立設定檔 ```shell= sudo cp config.json.example config.json sudo bin/setup ``` ### ==npm安裝== ```shell= sudo npm install -g ``` ### ==設定和資料庫的連線== ```sell= sudo vi /opt/codimd/.sequelizerc ``` #### 'url': 'mysql://root:XXXXXXX@localhost:3306/hackmd'(==改==) ![](https://i.imgur.com/nFROCmQ.png) ### ==設定 config.json== #### database(username.password改一下) ```shell "db": { "username": "root", "password": "root", "database": "codimd", "host": "localhost", "port": "3306", "dialect": "mysql" } ``` #### ldap ```shell "ldap": { "url": "ldap://IP", "bindDn": "", "bindCredentials": "", "searchBase": "", "searchFilter": "(&(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{username}})))", "searchAttribute": "" } ``` ### ==啟動服務== - cd /opt/codimd - sudo npm run build - sudo node_modules/.bin/sequelize db:migrate - sudo npm start ## npm各式error ### ==缺少webpack== ![](https://i.imgur.com/sldeKIH.png) #### 如紅框處所說,這個error是缺少webpack,所以安裝上去就好了 ```bash= sudo npm install -g webpack ``` ### ==缺少webpack-cli== ![](https://i.imgur.com/7TDOJlK.png) #### 如紅框處所說,這個error是缺少webpack-cli,所以安裝上去就好了 ```bash= sudo npm install webpack-cli -g ``` ### ==安裝mysql2== ![](https://i.imgur.com/5ZeaGwB.png) #### 這個錯誤通常會在這個步驟出現 ```bash= sudo node_modules/.bin/sequelize db:migrate ``` #### 這時候請下來安裝 ```bash= sudo npm install mysql2 ``` ### ==缺少套件的error== #### 這個error通常都會出現在"npm start"時(圖一) #### 這時請先下""npm install -g webpack"" #### 這時請自行google尋找安裝指令,收尋的關鍵字可以下"npm + 空白 + 缺少的套件 + install",例如圖一是缺少scrypt,所以收尋時要下"npm scrypt install" #### 圖一![](https://i.imgur.com/SUxorj1.png) ### ==安裝套件的error(一)== #### 圖二![](https://i.imgur.com/ylSxfZK.png) #### 圖二中的error出現了"permission denied" #### 這時請注意自己是否有在指令前加sudo,如果沒有請重新下指令並加sudo #### 如果一樣請嘗試用 "sudo su" 或是 "sudo -s" 切換成root權限,兩者的差異請查看下方的網址說明 https://kknews.cc/zh-tw/tech/gv4kngl.html ### ==安裝套件的error(二)== #### 當"permission denied"的問題解決後,如果一樣會出現error,請接著嘗試清除快取 ```shell= ## 清除快取 sudo npm cache clean -f ##更新節點和NPM sudo npm cache clean -f sudo npm install -gn sudo n 4.4.5 sudo npm install npm -g ##刪除其他Node-gyp模塊 sudo npm uninstall node-gyp -g sudo npm uninstall node-gyp ##最後一步 npm rebulid ``` #### 做完上面的指令後再嘗試安裝套件 ## ==完成== ![](https://i.imgur.com/OzBdart.png) ## 四、資料上檔 --- ## 以下服務都得設定(做完請打勾) ### 創建帳號 - [ ]創建自己的帳號 - [ ]創建組長的帳號 ### 修改主機名稱 - [ ]修改為服務名稱 ### APT - [ ]更改source來源 - [ ]apt update - [ ]apt upgrade ### NTP - [ ]成功系統校時 - [ ]crontab定期排程每天系統校時 ### Zabbix - [ ]zabbix-agent成功設定,且server顯示綠燈 ### 備份 - [ ]資料成功上檔還原 - [ ]備份/etc - [ ]備份網頁根目錄下所有檔案 - [ ]mysqldump備份資料庫 - [ ]有成功把備份資料傳送到備份機 - [ ]crontab定期排程每天備份 - [ ]crontab定期排程每天刪除備份 ## 以下相關服務才須設定 ### Apache - [ ]關閉目錄瀏覽 - [ ]關閉版本顯示 - [ ]修改回應人數上限 - [ ]修改同時讀取網頁人數上限 - [ ]設定虛擬目錄 443但不強轉 - [ ]禁止在瀏覽器直接存取.git、.hg、bzr、cvs、.svn資料夾,導引到 404 錯誤頁面 - [ ]HttpOnly - [ ]改掉 400/401/403/404/500/501/502/503/504 的訊息 - [ ]修改/etc/apache2/site-enable/000-default.conf為smt_cmrdb_01.conf ### PHP - [ ]更改上傳、POST大小為20MB - [ ]關閉error顯示 - [ ]設定PHP時區為Asia/Taipei - [ ]關閉PHP版本資訊 - [ ]設定HttpOnly ### Mariadb - [ ]連線人數上限調整成1000 - [ ]創建個人帳號 - [ ]創建組長帳號 ## 一、基本主機設定 請參考[行雲者伺服器-基本主機設定](https://hackmd.io/@CMRDBSMT/H1IG78EZB) --- ## 二、套件版本 (可安裝後再填寫) 1. Linux:16.04 1. 網頁服務套件: 1. 資料庫套件: 1. 網頁開發程式: --- ## 三、服務安裝步驟 1. 網頁服務套件: 1. 資料庫套件: 1. 確認服務正常運作: ![](https://i.imgur.com/BY7mLRb.png) ![](https://i.imgur.com/xH5M8zc.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully