【问题标题】:How to enable two wbesite to work on Nginx Digital ocean server如何让两个网站在 Nginx 数字海洋服务器上工作
【发布时间】:2016-04-20 18:20:51
【问题描述】:

所以在按照本教程在我的 NginX 服务器上实现两个网站的同时。

Lin to the Website

我创建了两个文件夹如下

sudo nano /etc/nginx/sites-available/ideconnect.com

我的文件是这样的

server {
        listen 80;
        listen [::]:80;

        root /var/www/ideconnect.com/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name ide-portal.com www.ide-portal.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

然后是其他网站

sudo nano /etc/nginx/sites-available/iclock.com

server {
        listen 80 ;
        listen [::]:80;

        root /var/www/iclock.com/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name iclock.in www.iclock.in;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

我也正确地创建了符号链接

sudo ln -s /etc/nginx/sites-available/ideconnect.com /etc/nginx/sites-enabled/ideconnect.com



sudo ln -s /etc/nginx/sites-available/iclock.com /etc/nginx/sites-enabled/iclock.com

之后,当我到达我的 ip 地址时,我只能看到默认的 Nginx 页面,现在 info.php 配置页面也不可见。

任何帮助将不胜感激

谢谢

【问题讨论】:

    标签: php nginx digital-ocean


    【解决方案1】:

    您可以从以下两点开始检查:

    • 你重启 nginx 了吗?
    • 您确定您的 nginx 配置设置为包含.com 文件吗?我认为默认是包含所有.conf 文件。您可以在您的 nginx 配置文件中检查它,然后对其进行调整或修改符号链接的扩展名。

    【讨论】:

    • 我现在正在获取我的 html 页面,并且允许 .com 作为文件名。但是当我上传我的 Laravel 网站时,我收到了以下错误 Mcrypt PHP extension required 。 www.ideportal.com/public
    • @Vikram 那么问题出在哪里,您需要重新启动 nginx 吗?顺便说一句,安装 php 扩展应该很容易,但取决于您的操作系统。
    • 这是我的浏览器问题,我只是按了 ctrl+f5 然后它开始搜索页面。我在 Digital Ocean 提供商上运行 Ubuntu 14.04
    • @Vikram 我不使用 Ubuntu,但如果我没记错的话,它会像 # apt-get search php 来搜索 php 相关的软件包,然后你可以使用 # apt-get install ... 安装它们。你可能需要mcrypt 和php5-mcrypt 包。
    • 谢谢 是的,我发现 ini 文件非常简单。我会尝试安装这些软件包。我是 Godaddy VPS 用户,所以一切都是开箱即用的,最近切换到 DO 并安装了 LEMP 堆栈,对我来说有点复杂:D
    猜你喜欢
    • 2019-06-01
    • 2021-03-29
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多