I want to use apache and node together on amazon ec2 ubuntu server, and I have very little knowledge of server configuration. I have to run this code:
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');
});
I followed this SO link:
Apache and Node.js on the Same Server
and edited /etc/apache2/sites-available/000-default.conf
(Should I use /etc/apache2/apache2.conf
?). It looks like:
<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>
But it shows this error:
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.
If I also tried removing two lines:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
And tested on browser, it gives this error:
I also tried this solution, but no success:
<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>
What can I do?