linux nginx 部署靜態網頁

安裝nginx環境

安裝環境

yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel

在usr/local目錄下新建nginx文件夾

cd /usr/local
mkdir nginx

進入nginx文件夾
cd nginx

下載nginx的tar包
wget http://nginx.org/download/nginx-1.9.7.tar.gz

解壓tar
tar -zxvf nginx-1.9.7.tar.gz

安裝nginx
./configure

執行make
make

執行make install
make install

進入sbin
cd sbin

啟動
sudo ./nginx

查詢nginx.conf是否正確
/usr/local/nginx/sbin/nginx -t

部署靜態文件

cd nginx
vim conf/nginx.conf

 server {
        listen       80;
        server_name  _;
        #root /usr/local/nginx/nginx-1.9.7/web/;      # 靜態頁面根目錄
        #index index.html;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/local/nginx/nginx-1.9.7/web/;
            index  index.html;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
重啟:./sbin/nginx -s reload
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容