Jackson
  • 請先讀我
  • 目錄
  • LYNX INDOOR2
    • LYNX INDOOR 2
    • 歡迎
    • 讓我們開始吧
    • 01. 放置攝影機
    • 02. 攝影機供電
    • 03. 下載 TEND SECURE APP
    • 04. 啟動 TEND SECURE APP
    • 攝影機 LED 燈
    • 有限的兩年製造商的保修
  • Vim
    • 序
    • 安裝
    • 普通模式指令
      • 移動
      • 搜尋
      • {motion}
      • 視窗、標籤頁、緩衝區
      • 拼寫檢查器
      • 文件管理器
    • 可視模式
    • 插入模式指令
    • Ex命令模式指令
      • 自動補齊
      • [range] {address}
      • 視窗、標籤頁
      • 緩衝區
      • 暫存器
      • ex-flags
      • Quickfix
      • tags
      • 文件管理器
    • 終端模式
    • 搜尋模式指令
      • {pattern}
      • magic
    • 環境設定
      • 環境變數
      • 映射
      • try catch
      • autocmd
      • 編輯器高亮顏色
    • 設定 help 文件中文版
    • 交換文件
    • 比較檔案
      • 解決 git 衝突
    • 函數庫
    • 插件推薦
      • 代碼
        • vim-snippets
        • coc
          • coc-snippets
          • coc-phpls
          • coc-json
          • ccls
          • VimScript Language Server
          • coc-prettier
        • deoplete
        • ale
          • C
          • HTML
          • Javascript
        • tabnine
        • php-cs-fixer
        • NERD Comment
        • ctags
      • 外觀
        • Dracula
        • NERDTree
        • airline
        • css color
        • coc-explorer
        • purity
        • startify
        • vim-mundo
      • 插件管理器
        • vim-plug
        • 原生插件管理
        • Vundle
      • Git
        • vim-fugitive
        • gv.vim
      • 分析插件
      • surround
      • Auto Pairs
      • visual-star-search
      • vim-tmux-navigator
    • 什麼是 vimrc
      • 設定檔案配置
      • ftplugin
  • 終端
    • 序
    • bash 腳本
      • 基礎
      • 環境變數
      • 正規表示式
      • 參數
      • 常用內建指令
        • 輸出
        • 捕捉中斷
        • shell 選項
      • 條件判斷
      • 迴圈
      • 函式
      • Windows 上使用 bash
      • 更新 bash
    • 指令
      • bash
        • 程序
        • 使用者與群組
        • 分析網路,檢測並與網路介面卡進行互動
        • 查看檔案與目錄
        • 建立與修改檔案或目錄
        • 搜尋
        • 壓縮與打包
        • 備份
        • 重導向
        • 寄信
        • 操作終端機
        • 另外安裝的指令
          • jq JSON 剖析器
          • wget
      • zsh
        • alias
      • Linux
        • 排程
      • 目錄路徑
      • 萬用字元
    • tmux
      • 未進 tmux 的終端指令
      • 進入到 tmux 指令
      • 進入到 tmux 的快捷鍵
      • 命令提示指令
      • 配置 tmux
      • 插件推薦
        • 插件管理器
        • vim-tmux-navigator
    • 插件推薦
      • 外觀
        • Gogh
        • purity
        • Dracula
        • powerline
      • zsh
        • zsh-syntax-highlighting
        • zsh-autosuggestions
  • Git
    • 序
    • 常用指令
    • 切換帳號
  • 作業系統
    • kali
      • 快捷鍵
      • E: unable to locate package
      • 中文亂碼和中文輸入
      • 命令提示字元修改成 Windows 格式
    • mac os
      • 架站 MAMP
        • Apache
        • PHP
        • MySQL
        • phpMyAdmin
        • localhost https
    • Ubuntu
      • 安裝 PHP
      • 安裝 Nginx
  • AWS
    • 序
    • Amazon EC2
  • WordPress
    • localhost ftp 連線問題
    • 強制修改信箱帳號
    • bitnami 登入 Wordpress
  • 影片剪輯
    • 序
    • 自動生成字幕
  • 其它
    • 鍵盤符號中英文
Powered by GitBook
On this page
  • 說明
  • 安裝步驟
  • 使用套件管理器安裝
  • 檢查安裝是否成功
  • 啟動關閉 Nginx 服務
  • 配置 PHP

Was this helpful?

  1. 作業系統
  2. Ubuntu

安裝 Nginx

說明

Nginx 為伺服器,一般安裝伺服器有 Apache 和 Nginx 關於 Nginx 和 Apache 比較,這裡就不再多做說明 主要以安裝 Nginx 為主

安裝步驟

請先確保安裝之前,沒有其他程序佔用 80 port 或 443 port 80 port 是 http 443 port 是 https

使用套件管理器安裝

先更新套件管理器再安裝 Nginx 安裝之前會告訴你將要安裝哪些套件,你需要先按 Y(yes) 確認

$ sudo apt update
$ sudo apt install nginx

安裝完成後會自己啟動

檢查安裝是否成功

$ sudo systemctl status nginx

你會看到一大堆訊息 其中以下這條訊息 active (running)代表已經啟動了 Active: active (running) since Fri 2020-06-05 14:27:00 UTC; 1 day 19h ago

如果你系統有設定防火牆,記得要打開 80 port 和 443 port

現在在瀏覽器輸入你的 Ubuntu IP 就會看到 Welcome to nginx http://你的IP

你的 IP 如果是雲端伺服器,應該會看到 IP 訊息 如果是本機就看本機的網路 IP 即可

啟動關閉 Nginx 服務

$ sudo systemctl stop nginx 終止 Nginx

$ sudo systemctl start nginx 啟動 Nginx

$ sudo systemctl restart nginx 重新啟動 Nginx

$ sudo systemctl reload nginx 重新載入 Nginx 如果有修改配置,可以使用此指令

配置 PHP

安裝完 PHP 後需要配置 Nginx

預設檔案在 /etc/nginx/sites-available/default

/etc/nginx/sites-available/default
server {
    略
    index index.php 略
 
    略
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
 
    location ~ /\.ht {
        deny all;
    }
}

index 就是入口網站的預設讀取的檔案 如果有多個會依序找檔案,找到的第一個為主

假設安裝的是 php7.4 上面就是輸入 php7.4-fpm.sock

$ sudo nginx -t 測試設定有沒有問題

如果沒問題就會看到以下訊息

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

接下來重啟 Nginx 就可以了 $ sudo systemctl restart nginx

Previous安裝 PHPNext序

Last updated 4 years ago

Was this helpful?