Linux Tomcat 80端口 Port 80 required by Tomcat v8.5 Server at localhost is already in use.

Port 80 required by Tomcat v8.5 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

由於裝上了ubuntu,就在eclipse上設置tomcat端口爲80,可是就顯示說已被佔用,不過我電腦纔剛裝上ubuntu,正常應該是沒有其餘程序被佔用,而後在stackoverflow上發現的一個解答就是說linux不開放1024如下的端口給非root用戶。linux

上網找了好多解答,我感受仍是用nginx比較靠譜,畢竟之後應該會用nginx比較多,因此我就用nginx解決了。nginx

利用nginx把80端口的轉發到8080(我在tomcat上設置的1024以上的端口)。ubuntu

nginx在ubuntu上安裝的簡單方法,也能夠用其餘方法安裝,隨習慣tomcat

sudo apt-get install nginxeclipse

個人nginx的配置文件在/etc/nginx/nginx.conf,由於配置文件默認include了/etc/nginx/sites-available/default,這個default就是初始的nginx配置文件,裏面設置了當前nginx的默認端口,也就是80,固然也能夠修改成其餘的。ui

我就在default文件裏的server裏,修改了location爲this

location / {
 44                 # First attempt to serve request as file, then
 45                 # as directory, then fall back to displaying a 404.
 46                 # try_files $uri $uri/ =404;
 47                 proxy_pass http://localhost:8080;
 49                 index index;
 50                 root /;
 51         }

而後就保存,在命令行裏輸入sudo nginx -s reload命令行

沒有顯示錯誤就表明對了,而後我就啓動tomcat,在地址欄輸入了localhost,成功跳轉了tomcat的項目裏了。code

相關文章
相關標籤/搜索