コンパイルインストール
インストールメーク:
yum-y install gcc atomake atof libtool make
セットアップg++:
yum-y install gcc-c++
PCREライブラリ:
NginxはPCREを必要としています。PCRE正則表現文法にはNgixのRewriteモジュールとHttpコアモジュールが使用されています。ダウンロード先はhttp://www.pcre.org/私達もyumでインストールできます。yum-y install pcre pcre-devel
zlibライブラリ:
zlibライブラリは圧縮アルゴリズムを提供しています。ダウンロード先はhttp://www.zlib.net/また、yumでインストールすることもできます。yum-y install zlib-devel
OpenSSL:
Nginnxでは、サーバーがセキュリティページを提供する場合、OpenSSLライブラリを使用する必要があります。ダウンロード先はhttp://www.openssl.org/また、yumでインストールすることもできます。yum-y install openssl-devel
ダウンロード
wgethttps://nginx.org/download/nginx-1.12.2.tar.gz
tar zxf nginx-1.12.8 tar.gz
cd nginx-1.12.2
./configure
----------
xiここではsslモジュールを加えることを提案します。
./configure--with-http_同前module
------------------
make&make install
make installはerrorを提示しないと大丈夫です。
Nginnxはデフォルトでインストールされます。/usr/local/inxディレクトリには、cdから/usr/local/nginx/sbin/ディレクトリには、ngixバイナリ実行ファイルがあります。直接運転すればNgixを起動できます。
起動:/usr/local/inx/sbin/inx
クローズ:/usr/local/inx/sbin/inx -s stop
再起動:/usr/local/nginx/sbin/nginx-s reload
サービスとして設定し、自動起動します。
ninxのプロファイルを変更して、phpファイルの解析をサポートします。
vi/usr/local/inx/conf/nginx.com nf
location~\.php${ノードのコメントを削除します。
nginxのデフォルトのwebパスを変更します(元は/usr/local/nginx/です)
vi/usr/local/inx/conf/nginx.com nf
ウェブサイト/wwwに修正
元のlocation項目の下にスタティックファイル(css,js,写真)を処理するためのlocation項を追加します。
噬静的資源処理location~.*.(js 124; css𞓜gif𞓜jpg 124; jpeg𞓜pg𞓜bmp𞓜sht) { root/website/www/nzg; if(-f$request-ufilename){ expires 1 d break; } }
urlで書き換え、index.phpを隠します。
同時にもう一つのlocation項目を設定する必要があります。
location/{ root/website/www/nzg; index index.php; if(!-e$request-ufilename){ #方式1 rewrite^/(.*)/index.php last; } #tryfiles$uri/index.php$isuugs$args; #方式2 }
ここでは2つの方法でindex.phpを隠すことができます。
よく使うserverノードの配置
vi index.php
追加
保存
nginxを再起動すればブラウザで閲覧できます。
-------------。
本機のhostsファイルの設定
追加
192.168.1.222 mystest.cn
私は仮想マシンにnginxをインストールしています。192.168.1.222は仮想マシンシステムのイントラネットipです。もしnginxが本機にインストールされたら127..0.1を使います。
--------------。
エラーが発生した場合、403解決策
ウェブディレクトリを777のパーミッションに設定します。-Rは下への再帰を表します。
chmod-R 777/website/www
==========は異なるサブプロファイル構成の異なる局======
メインプロファイルnginx.com nfのhttpノードに追加します。
include/website/inx-conf/*.conf;
ここのカタログはカスタマイズカタログです。
最後に設定を再読み込みする必要があります。
実行 service nginx reload
======アクセスログを閉じる========================
yum-y install gcc atomake atof libtool make
セットアップg++:
yum-y install gcc-c++
PCREライブラリ:
NginxはPCREを必要としています。PCRE正則表現文法にはNgixのRewriteモジュールとHttpコアモジュールが使用されています。ダウンロード先はhttp://www.pcre.org/私達もyumでインストールできます。yum-y install pcre pcre-devel
zlibライブラリ:
zlibライブラリは圧縮アルゴリズムを提供しています。ダウンロード先はhttp://www.zlib.net/また、yumでインストールすることもできます。yum-y install zlib-devel
OpenSSL:
Nginnxでは、サーバーがセキュリティページを提供する場合、OpenSSLライブラリを使用する必要があります。ダウンロード先はhttp://www.openssl.org/また、yumでインストールすることもできます。yum-y install openssl-devel
ダウンロード
wgethttps://nginx.org/download/nginx-1.12.2.tar.gz
tar zxf nginx-1.12.8 tar.gz
cd nginx-1.12.2
./configure
----------
xiここではsslモジュールを加えることを提案します。
./configure--with-http_同前module
------------------
make&make install
make installはerrorを提示しないと大丈夫です。
Nginnxはデフォルトでインストールされます。/usr/local/inxディレクトリには、cdから/usr/local/nginx/sbin/ディレクトリには、ngixバイナリ実行ファイルがあります。直接運転すればNgixを起動できます。
起動:/usr/local/inx/sbin/inx
クローズ:/usr/local/inx/sbin/inx -s stop
再起動:/usr/local/nginx/sbin/nginx-s reload
サービスとして設定し、自動起動します。
ninxのプロファイルを変更して、phpファイルの解析をサポートします。
vi/usr/local/inx/conf/nginx.com nf
location~\.php${ノードのコメントを削除します。
nginxのデフォルトのwebパスを変更します(元は/usr/local/nginx/です)
vi/usr/local/inx/conf/nginx.com nf
ウェブサイト/wwwに修正
元のlocation項目の下にスタティックファイル(css,js,写真)を処理するためのlocation項を追加します。
噬静的資源処理location~.*.(js 124; css𞓜gif𞓜jpg 124; jpeg𞓜pg𞓜bmp𞓜sht) { root/website/www/nzg; if(-f$request-ufilename){ expires 1 d break; } }
urlで書き換え、index.phpを隠します。
同時にもう一つのlocation項目を設定する必要があります。
location/{ root/website/www/nzg; index index.php; if(!-e$request-ufilename){ #方式1 rewrite^/(.*)/index.php last; } #tryfiles$uri/index.php$isuugs$args; #方式2 }
ここでは2つの方法でindex.phpを隠すことができます。
よく使うserverノードの配置
server {
listen 80;
#server_name 47.52.110.110;
server_name mytest.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /website/61group;
index index.php index.html index.htm;
if (!-e $request_filename){ # 1
rewrite ^/(.*) /index.php last;
}
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
root /website/61group;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf|mp3|mp4|ttf|woff|svg|eot|txt|html|htm)$
{
root /website/61group;
if (-f $request_filename) {
expires 1d;
break;
}
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
ログイン/website/wwwディレクトリvi index.php
追加
保存
nginxを再起動すればブラウザで閲覧できます。
-------------。
本機のhostsファイルの設定
追加
192.168.1.222 mystest.cn
私は仮想マシンにnginxをインストールしています。192.168.1.222は仮想マシンシステムのイントラネットipです。もしnginxが本機にインストールされたら127..0.1を使います。
--------------。
エラーが発生した場合、403解決策
ウェブディレクトリを777のパーミッションに設定します。-Rは下への再帰を表します。
chmod-R 777/website/www
==========は異なるサブプロファイル構成の異なる局======
メインプロファイルnginx.com nfのhttpノードに追加します。
include/website/inx-conf/*.conf;
ここのカタログはカスタマイズカタログです。
http {
#
include /website/nginx-conf/*.conf;
}
サブプロファイルの内容はserverノードのみ必要です。最後に設定を再読み込みする必要があります。
実行 service nginx reload
======アクセスログを閉じる========================
#access_log logs/access.log main;
access_log off;
Nginx最適化