同时运行apache和节点 - 服务器遇到内部错误或配置错误

时间:2016-06-19 03:24:36

标签: node.js ubuntu amazon-ec2 proxy apache2

我想在amazon ec2 ubuntu服务器上一起使用apache和node,而且我对服务器配置知之甚少。我必须运行此代码:

 var http = require('http');

 http.createServer(function(req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('hello world!\n');
 }).listen(8080, '0.0.0.0', function() {
   console.log('Server running on port 8080');
 });

我按照这个SO链接: Apache and Node.js on the Same Server  并编辑/etc/apache2/sites-available/000-default.conf(我应该使用/etc/apache2/apache2.conf吗?)。它看起来像:

 <VirtualHost *:80>
         ServerAdmin webmaster@localhost
         DocumentRoot /var/www/html

         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined

      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_http_module modules/mod_proxy_http.so

      ProxyPass /node http://localhost:8080/
  </VirtualHost>

但它显示了这个错误:

 ubuntu@ip-172-31-42-165:~/test$ sudo nano /etc/apache2/sites-available/000-default.conf 
 ubuntu@ip-172-31-42-165:~/test$ sudo service apache2 restart 
  * Restarting web server apache2                                                                                                                                [fail] 
  * The apache2 configtest failed.
 Output of config test was:
 [Sun Jun 19 02:58:50.175584 2016] [so:warn] [pid 11702:tid 139896007923584] AH01574: module proxy_module is already loaded, skipping
 apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 28 of /etc/apache2/sites-enabled/000-default.conf: Cannot     load modules/mod_proxy_http.so into server:    /etc/apache2/modules/mod_proxy_http.so: cannot open shared object file: No    such file or directory
 Action 'configtest' failed.
  The Apache error log may have more information.

如果我也尝试删除两行:

       LoadModule proxy_module modules/mod_proxy.so
       LoadModule proxy_http_module modules/mod_proxy_http.so

在浏览器上测试,它会出现此错误:

enter image description here

我也试过这个解决方案,但没有成功:

  <VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

 ProxyRequests off

 <Proxy *>
   Order deny,allow
   Allow from all
 </Proxy>

  ProxyPass /node http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/
 </VirtualHost>

我该怎么办?

0 个答案:

没有答案