Nginx インストール

Nginxインストール
[root@centos ~]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root@centos ~]# yum -y install --enablerepo=nginx nginx
[root@centos ~]# nginx -v ←nginxのバージョンを確認
nginx version: nginx/1.12.2
nginx.conf編集
[root@centos ~]# vi /etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server_tokens off; ←追加(バージョン情報を隠す)
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}
Nginx起動
[root@centos ~]# systemctl start nginx ←nginx起動
[root@centos ~]# systemctl enable nginx ←nginx自動起動
[root@centos ~]# systemctl is-enabled nginx ←自動起動を確認
enabled
ブラウザで確認 (http://ドメイン名/ にアクセス)

Home PageTop