centos 7 安装配置nginx

安装

1: sudo yum update

2: sudo yum install Nginx

启动

sudo service Nginx start

配置(多个并行配置)

1,添加用户权限www-data

/usr/sbin/groupadd -f www-data
/usr/sbin/useradd -g www-data www-data

2,修改Nginx.conf

sudo vim /etc/Nginx/Nginx.conf

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;
        }
}

5:添加链接

cd ../sites-enabled
sudo ln -s ../sites-available/default_80 default_80

6:重启Nginx

sudo service reload

7:创建目录:/var/www/html

并给html设置www-data 权限


完成。

相关文章

有时候CentOS工作在无互联网的环境下,需要在离线环境下安装一些组件,这次实现的是模拟在离线环境下安...
首先参照https://www.cnblogs.com/wdw984/p/13330074.html,来进行如何安装Centos和离线下载rpm包。 离...
有两个.NET CORE3.1网站部署在CentOS7上(内网IP是192.168.2.32),现在想实现访问http://192.168.2.32...
1、yum -y install vsftpd 安装vsftpd 2、配置vsftpd的配置文件(/etc/vsftpd/vsftpd.conf)主要修改以...
首先去mysql官网下载mysql的离线rpm安装包(https://downloads.mysql.com/archives/community/) Mysql...
第一步下载erlang环境并安装: wget https://packages.erlang-solutions.com/erlang/rpm/centos/7/x86_...