node.js - 哪个是在 ubuntu 16.04 中同时安装 Nginx 和 apache 的最佳方式
问题描述
我有一个 VPS 服务器并尝试安装Apache和Nginx以在Ubuntu 16.04中协同工作,但使用不同的服务器名称和域。
所以,我有 apache 到端口 8000 和 nginx 到端口 8080。
Nginx 确实转到 8080 端口,因为使用NodeJs,这在路由https://localhost:8080/后面使用
Apache 使用 Laravel 5.5 和 PHP。
我已经配置到 Apache
/etc/apache2/sites-available/000.default.conf
<VirtualHost *:8000>
ServerName www.myanotherdomainname.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/ect/apache2/ports.conf
和Listen 8000
对于 Nginx 中/etc/nginx/sites-available/default
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
和
server {
if ($host = www.mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name geckode.la www.mydomain.com;
return 404; # managed by Certbot
}
在www.mydomain.com中,NodeJs 运行的 script.js 运行良好
但是在www.myanotherdomainname.com中,返回404 Not Found nginx/1.10.3 (Ubuntu)
它甚至似乎都没有运行 apache
我需要知道使用 Nodejs 运行 apache 和 nginx 的最佳方式。
Apache状态和Nginx运行没有任何问题。
谢谢
解决方案
它只是按照你的吩咐去做。让我们运行一下您的配置:
if ($host = www.mydomain.com)
- 没有...
if ($host = mydomain.com)
- 还是不行...
return 404;
- 好的,糟糕,我的意思是 HTTP/1.1 404 Not Found
推荐阅读
- python - 如何在 Flask 中调用另一个函数
- r - boot() 函数内部的引导程序地址轮
- jquery - 如何获取数据表中切换开关的值,laravel
- python - 我无法将 .py 编译为 .exe(缺少 .dll 文件)
- amazon-web-services - AWS Neptune 是否需要访问互联网?
- android - 从 launchWhenStarted 调用多个视图模型方法不起作用
- python - 如何在 django-rest-framework 中使用 session_key
- firebase - 如何在 Flutter 项目中预览链接
- python - 使用python查找变量之间的相关性
- linq - 匹配 sql 时,Linq 左外连接不起作用