安装
1: sudo yum update
2: sudo yum install Nginx
启动
sudo service Nginx start
配置(多个并行配置)
/usr/sbin/groupadd -f www-data /usr/sbin/useradd -g www-data www-data
sudo vim /etc/Nginx/Nginx.conf
user www-data; worker_processes auto; pid /run/Nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/Nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3,ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/Nginx/access.log; error_log /var/log/Nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; include /etc/Nginx/conf.d/*.conf; include /etc/Nginx/sites-enabled/*; }
3:创建文件夹
cd /etc/Nginx/ sudo mkdir sites-available sudo mkdir sites-enabled
4:进入sites-available 文件夹
sudo vim default_80
default_80内容如下:
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.PHP to the list if you are using PHP index index.html index.htm index.Nginx-debian.html index.PHP; server_name _; location / { # First attempt to serve request as file,then # as directory,then fall back to displaying a 404. try_files $uri $uri/ =404; } }
cd ../sites-enabled
sudo ln -s ../sites-available/default_80 default_80
6:重启Nginx
sudo service reload
7:创建目录:/var/www/html
并给html设置www-data 权限
完成。