【发布时间】:2017-07-08 12:51:14
【问题描述】:
我正在尝试部署一个小 php 应用程序已经是第三天了。 我们将我们的应用程序(即 3 个 rails 应用程序和 1 个 php)移动到同一台服务器上。 Rails 应用程序运行良好。 PHP 没有。 我从来没有真正部署过 PHP 应用程序,所以我是通过指南来完成的。到目前为止,我得到了这种情况: 如果我尝试在浏览器中打开 PHP 应用程序,我会看到默认的 Apache 页面。如果我刷新页面,它将显示 index.php 文件的内容,但显示为空白文本。再次刷新 - 默认 Apache 页面,然后再次刷新 - index.php 的内容。
我的设置:
nginx/sites-available/my.site(在启用的站点中启用)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/my.site/httpdocs;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name my.site www.my.site;
location / {
proxy_pass http://localhost:8000;
include /etc/nginx/proxy_params;
}
location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
expires 30d;
}
location @proxy {
proxy_pass http://127.0.0.1:8000;
include /etc/nginx/proxy_params;
}
location ~* \.php$ {
proxy_pass http://127.0.0.1:8000;
include /etc/nginx/proxy_params;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
apache2/sites-available/my.site
ServerName my.site
ServerAlias www.my.site
ServerAdmin webmaster@localhost
DocumentRoot /var/www/my.site/httpdocs
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
apache2/ports.conf
NameVirtualHost 127.0.0.1:8000
Listen 8000
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
在休息日工作,不知道如何修复服务器。任何建议表示赞赏。
【问题讨论】:
-
我能知道你为什么使用 nginx 作为 apache 的代理吗?
-
@Albert221 我没有合适的答案。我刚开始 google 'ubuntu php apache deploy' 并且这些指南出现了。你能提供更好的解决方案吗?
-
我认为您不了解您要达到的目标。 Nginx 和 Apache 都是网络服务器,而 PHP 是一个(非常普遍的)解释 .php 代码的程序。您通常不希望同时使用 nginx 和 apache。阅读这两个并选择更符合您要求的一个:digitalocean.com/community/tutorials/…