Linux(centos7)nginx構成

1.Nginxと関連コンポーネントをダウンロードします

wget http://nginx.org/download/nginx-1.6.2.tar.gz
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz


wget http:// zlib .net / zlib-1.2.11.tar.gz

wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

2. C ++コンパイル環境をインストールします。すでにインストールされている場合は、スキップします。

yum install gcc-c ++

が確認のために表示され、Yを入力します

3.Nginxと関連コンポーネントをインストールします

opensslのインストール

  tar -zxvf openssl-fips-2.0.10.tar.gz

  cdopenssl-fips-2.0.10

  ./config && make && make install

zlibのインストール

  tar zxvf zlib-1.2.11.tar.gz

  cd zlib-1.2.11

  ./configure && make && make install

pcre install

  tar zxvf pcre-8.40.tar.gz

  cd pcre-8.40

  ./configure && make && make install

 

nginxのインストール

  tar zxvf nginx-1.10.2.tar.gz

  cd nginx-1.10.2

  ./configure && make && make install

 

nginxのインストールパスを表示する

whereis nginx

 

 

nginxバージョンを表示

  / usr / local / nginx / sbin / nginx - v

 

nginxを起動します

  / usr / local / nginx / sbin / nginx

 

ブラウザにIPを入力します。次のインターフェイスが表示されたら、インストールは成功します。

  

 

 nginxを閉じる

/ usr / local / nginx / sbin / nginx -s stop 


nginxコマンド启PIN

/ usr / local / nginx / sbin / nginx
停止:/ usr / local / nginx / sbin / nginx -s stop

構成ファイルのリロード:/ usr / local / nginx / sbin / nginx -s reload
重启:/ usr / local / nginx / sbin / nginx -s reopen
 

4.フロントエンドプロジェクトを構成します


1.プロジェクトを/ ** / nginx / htmlディレクトリに
配置します2.構成を構成します

サーバー{ リッスン80; server_name localhost;

#charset koi8-r;

#access_log logs / host.access.log main;

場所/ {
root html / ess-web /;#ess-webはパッケージ化されたプロジェクトフォルダー
index index.html index.htm;
try_files $ uri $ uri //index.html;      
}

#error_page 404 /404.html;

#静的ページ/50x.htmlにリダイレクトサーバーエラーページ
#の
error_page 500 502 503 504 /50x.html。
場所= / 50x.html { ルートhtml; }

location / cors / {# "
cors "はIDproxy_passを参照しますhttp://192.168.10.22:8080/;#"cors "が指すIPパス
}

#PHPスクリプトを127.0.0.1:80でリッスンしているApacheにプロキシします
##
location〜 \ .php $ { #proxy_pass http://127.0.0.1; #}

 

5.起動後のセルフスタート


新しい構成ファイル
/usr/lib/systemd/system/nginx.service

[ユニット]
説明= nginxAfter
= network.target

[サービス]
タイプ=
forkingExecStart = / usr / local / webserver / nginx / sbin / nginx
ExecReload = / usr / local / webserver / nginx / sbin / nginx -s reload
ExecStop = / usr / local / webserver / nginx / sbin / nginx -s quit
PrivateTmp = true

[インストール]
WantedBy = multi-user.target

 
systemctl enable xxx.service サービスブートを設定すると、サービスブート
systemctl disable xxx.service がキャンセル
systemctl stop xxx.service され、サービス
systemctl status xxx.service シャットダウンされてサービスのステータスが表示され ます。




おすすめ

転載: blog.csdn.net/qq_45533926/article/details/112180037