由于装上了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 nginx
eclipse
个人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