nginxの展開角度のプロジェクトの下でcentos7

フロントエンドのプロジェクトディレクトリを作成します。1.

/ varフォルダに

cd /var

/ varディレクトリにWWWフォルダを作成します。

mkdir www

の/ var / wwwディレクトリに、テスト用フォルダを作成します

cd www #进入www目录
mkdir test
2.アップロードフロントエンドコンパイラの/ var / www /のテストディレクトリにファイル
3. nginxのテストディレクトリと設定オプション

/etc/nginx/conf.d/ディレクトリを入力します。

cd /etc/nginx/conf.d/

設定は、default.confを開き、筆記試験

server {
    listen       80; # nginx监听端口
    server_name  localhost; #若有域名则将localhost替换为域名

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /var/www/test; #test项目路径
        index  index.html index.htm; #默认起始页
        try_files $uri $uri/ /index.html; #spa前端项目路由配置
    }

    #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   /usr/share/nginx/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;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
4.テスト展開
curl localhost #假设项目端口为80则为localhost

HTML文字列が返さなければならない異常なエラーステータスコードは成功しませんでした

5.エラーのトラブルシューティング
1)内部ホストカールを使用すると、クライアントマシンがアクセスすることはできませんアクセスすることができます

解決策:ホストファイアウォールのリスニングポートは現在開いているかどうかをチェック

查看当前主机开放的端口
firewall-cmd --list-ports

开放主机端口
firewall-cmd --add-port=80/tcp --permanent

关闭主机端口
firewall-cmd --remove-port=80/tcp --permanent

注:オープンまたはクローズは、ファイアウォールのポートを再起動する必要性を実行します

firewall-cmd --reload
2)内部および外部のホストがページにアクセスすることはできませんが、nginxのヒント403禁断のエラー・ページにアクセスすることができます

解決策:SELinuxはあなたがSELinuxをオフにすることができ、状態のために開放されていてもよいです

ビューSELinuxの状態

/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态

臨時休業(ない再起動が現在の設定が403エラーSELinuxを引き起こすことになっていることを確認するために使用することができます)

setenforce 0                  ##设置SELinux 成为permissive模式
                              ##setenforce 1 设置SELinux 成为enforcing模式

恒久的にSELinux(再起動する必要があります)を編集し、閉じ

vi /etc/selinux/config  # 将SELINUX=enforcing 改为 SELINUX=disabled

おすすめ

転載: www.cnblogs.com/somedaylight/p/12061506.html