mac下eclipse起服务器使用80端口

方法

  • 使用第三方代理软件nginx

步骤

  • 1、安装pcre

    • 下载pcre http://www.pcre.org/
    • 安装pcre

      $ cd ~/Downloads
      $ tar xvzf pcre-8.5
      $ cd pcre-8.5
      $ sudo ./configure --prefix=/usr/local
      $ sudo make
      $ sudo make install 
      
  • 2、安装Nginx

    • 下载Nginx http://nginx.org/

    • 安装Nginx

      $ cd ~/Downloads
      $ tar xvzf nginx-1.6.0.tar.gz
      $ cd nginx-1.6.0
      $ sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations"
      $ sudo make
      $ sudo make install
      
  • 3、开启Nginx

    • 将/usr/local/nginx/sbin加入到环境变量里
    • 运行

      $ sudo nginx 
      
    • 停止

      $ sudo nginx -s stop
      
  • 3、配置Nginx

    • 配置nginx,监听80端口,然后跳转到8080端口。在目录/usr/local/nginx/conf下找到配置文件nginx.conf,如下编辑

      server {
          listen       80;
          server_name  tv-lq.alibaba.net;
          add_header Cache-Control private;
          charset utf-8;
          fastcgi_intercept_errors on;
      
          location / {
              proxy_next_upstream http_502 http_504 error timeout invalid_header;
              proxy_pass http://127.0.0.1:8080;
              proxy_set_header Host $host;
              proxy_set_header X-Forwarded-For $remote_addr;
              proxy_intercept_errors on;
          }
      }