mySite 正在使用 www.mysite.com 中的 :8080,在 Linux 中使用 Apache Tomcat

mySite is working on :8080 not in www.mysite.com, Using Apache Tomcat in Linux

我搬到了一台新服务器,并在机器上安装了 Oracle Linux 操作系统和 Oracle 数据库。

然后根据这个 tutorial 我安装了 Apache - 7 和 JDK 1.8

但是当我尝试以 ww.mysite.com 访问它时,它不起作用。

但是当我尝试使用 ww.mysite.com:8080 访问时,我可以访问该站点。

如何更改我的网站以在 ww.mysite.com

上工作

我的 server.xml 文件如下:

<Connector
    port="8080"
    protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" 
    compression="on" 
    noCompressionUserAgents="gozilla, traviata"
    compressableMimeType="text/html,text/xml,text/css,image/svg+xml,image/gif,image/jpeg,image/png,text/plain,application/xhtml+xml,application/javascript,application/json,text/javascript"
    maxThreads="350"
    threadPriority="java.lang.Thread.MAX_PRIORITY"
    acceptCount="200"
/>

您需要将port="8080" 更改为port="80",因为80 是http 标准端口。当不在标准端口上时,需要添加调用的端口URL。 - 对于标准端口为 443 的 https 也是如此。 顺便提一句。不要忘记在更改 server.xml 后重新启动 Tomcat ;-)

-- 编辑

此外,您还应该注意您正在使用的系统以及路由器上的防火墙。您需要在那里为传入请求打开端口 80。但是你应该确保没有人可以破解你的 system/network.

为此,大多数人在 tomcat 前面使用 Apache HTTPD,例如过滤 SQL 注入等

-- 编辑

对于 tomcat 无法启动的情况,您可能还需要检查您系统上的其他东西是否已经在侦听端口 80。

-- 编辑

最后但并非最不重要的端口 <= 1024 是特权的,因此您需要 运行 tomcat 具有这些特权。

将第一行的端口改为80如下:

<Connector port="80" protocol="HTTP/1.1"
 connectionTimeout="20000"
 redirectPort="8443" 
compression="on" 
              noCompressionUserAgents="gozilla, traviata"
              compressableMimeType="text/html,text/xml,text/css,image/svg+xml,image/gif,image/jpeg,image/png,text/plain,application/xhtml+xml,application/javascript,application/json,text/javascript"
              maxThreads="350"
              threadPriority="java.lang.Thread.MAX_PRIORITY"
              acceptCount="200"
            />

我很高兴,

在尝试了很多东西之后。我找到了解决方案。

在 linux 终端上使用命令行 我安装了 httpd

sudo yum install httpd

然后我在 server.xml

中将端口号从 80 更改为 8080
<Connector
    port="8080"
    protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" 
    compression="on" 
    noCompressionUserAgents="gozilla, traviata"
    compressableMimeType="text/html,text/xml,text/css,image/svg+xml,image/gif,image/jpeg,image/png,text/plain,application/xhtml+xml,application/javascript,application/json,text/javascript"
    maxThreads="350"
    threadPriority="java.lang.Thread.MAX_PRIORITY"
    acceptCount="200"
/>

在 linux 命令行中,我将我的用户更改为 tomcat 用户。这是为了 apache tomcat 目的而创建的 link。 https://oracle-base.com/articles/linux/apache-tomcat-7-installation-on-linux

运行 阿帕奇 tomcat ->

./startup.sh

将用户更改为主用户并打开 httpd.conf 文件。

/etc/httpd/conf/httpd.conf

使用 vi linux 命令编辑文件

vi httpd.conf

加这个

<VirtualHost *:80>
    ServerName ww.mysite.com
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPass /     http://ww.mysite.com:8080/
    ProxyPassReverse /  http://ww.mysite.com:8080/
    ErrorLog logs/mysite.com-error_log
</VirtualHost>