【nginx】linux在线安装

news/2024/7/7 21:44:07 标签: nginx, centos, linux

安装

yum install epel-release
yum install nginx
nginx -V

安装成功
在这里插入图片描述

配置

修改/etc/nginx下的nginx.conf

user root; #修改为root
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65; #时延限制,65秒
    types_hash_max_size 2048;
    # client_max_body_size 10m; #传输数据大小限制,10M
    
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
		
		# gzip on; #gzip启用压缩
	    # gzip_buffers 32 4K;
	    # gzip_comp_level 6; #压缩比,1-9
        # gzip_min_length 100; # 当资源大于100字节时才压缩
	    # gzip_types application/javascript text/css text/xml text/html text/javascript application/json;
        # gzip_vary on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
	    root /myWeb/nginx-webapp/test/;  #修改为自己的地址
	    index index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

......

重新加载配置文件

nginx -t #检查配置文件
nginx -c /etc/nginx/nginx.conf #执行
nginx -s reload #重载
nginx -s reopen #重启

开放端口80

firewall-cmd --zone=public --list-ports # 查看已开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent # 开放80端口
firewall-cmd --reload # 重载防火墙
firewall-cmd --zone=public --list-ports # 确认80端口已打开

http://www.niftyadmin.cn/n/1503357.html

相关文章

【jenkins】linux在线安装及配置

安装 使用root权限 设置yum源并安装 wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key yum install jenkins端口号(默认8080)有冲突的话修改端口号&am…

Android Socket简单测试

这里是将pc作为server,设备作为客户端。Server端代码: public static final String SERVERIP "192.168.0.2"; public static final int SERVERPORT 51706; public void run() { try { System.out.println("S: Connecting..."); S…

【bug】axios请求mock.js失败

【vue】mock.js安装及使用 问题描述 post请求失败 请求没反应 get请求失败 返回页面HTML .vue this.$get(/gettest, {b:222}, (res) > {console.log(res)}) this.$post(/posttest, {a:111}, (res) > {console.log(res)})mock.js Mock.mock(/gettest, get, opt &g…

[Eclipse插件] 安装和使用JD-Eclipse插件

JD-Core 是一个免费的库,从一个或多个“.class”文件中 重构Java源代码。JD-Core可以用来恢复丢失的源代码,并深究Java运行时类库。支持Java 5的功能:如注释,泛型或键入“枚举” 。JD-GUI 和 JD-Eclipse都包括JD-Core。 JD-GUI 是…

【黑科技】读写优化 orz bdd

转自 bdd &#xff1a;http://www.cnblogs.com/kevince/p/3924688.html 读入优化&#xff1a; 1 inline int read()2 {3 char ch;4 bool flag false;5 int a 0;6 while(!((((ch getchar()) > 0) && (ch < 9)) || (ch -)));7 if(c…

nginx到tomcat

nginx 80端口转到tomcat&#xff08;8080端口&#xff09; nginx.conf server {listen 80;server_name somename;location / {proxy_pass http://localhost:8080;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-F…

java 静态(static)方法中调用接口(Service层)

Component public class JwtUtil {/*** 静态方法调用非静态接口层(Service层)*/public static JwtUtil jwtUtil; //声明对象PostConstruct //初始化public void init() {jwtUtil this;jwtUtil.userService this.userService;}Autowired //注入UserService userService;public…

springMVC无法跳转到jsp

为什么80%的码农都做不了架构师&#xff1f;>>> 项目架构是代码生成器做的&#xff0c;不是web项目但是需要完成web项目的功能&#xff0c;通过tomcat插件启动&#xff0c;SpringspringMVCmybatis;各种配置都没有问题&#xff0c;可以进入后台controller,但是无法跳…