PHP应用程序部署Ubuntu 16.04 nginx apache设置
这已经是我尝试部署一个小php应用程序的第三天了。 我们正在将我们的应用程序(3个rails应用程序和1个php)移动到同一个服务器。 Rails应用程序运行良好。PHP没有。 我从来没有真正部署过PHP应用程序,所以我是通过指南来完成的。到目前为止,我了解到这种情况: 如果我尝试在浏览器中打开PHP应用程序,我会看到默认的Apache页面。如果我刷新页面,它将显示index.php文件的内容,但显示为空白文本。再次刷新-默认Apache页面,再次刷新-index.php的内容 我的设置: nginx/sites available/my.site enabled in sites enabled apache2/可用站点/我的站点 apache2/ports.conf 在休息日工作时,不知道如何修理服务器。非常感谢您的建议。nginx config apache配置 PHP7模块 php5模块 包括例如php7.0 mod 虚拟主机配置apachePHP应用程序部署Ubuntu 16.04 nginx apache设置,php,apache,nginx,Php,Apache,Nginx,这已经是我尝试部署一个小php应用程序的第三天了。 我们正在将我们的应用程序(3个rails应用程序和1个php)移动到同一个服务器。 Rails应用程序运行良好。PHP没有。 我从来没有真正部署过PHP应用程序,所以我是通过指南来完成的。到目前为止,我了解到这种情况: 如果我尝试在浏览器中打开PHP应用程序,我会看到默认的Apache页面。如果我刷新页面,它将显示index.php文件的内容,但显示为空白文本。再次刷新-默认Apache页面,再次刷新-index.php的内容 我的设置: ng
原始帖子我能知道你为什么使用nginx作为apache的代理吗?@Albert221我没有合适的答案。我刚刚启动了谷歌的“ubuntu php apache deploy”,这些指南就出现了。你能提供更好的解决方案吗?我认为你不明白你想要实现什么。Nginx和Apache都是Web服务器,PHP是一个解释.PHP代码的程序。您通常不会同时需要nginx和apache。阅读这两个选项,选择一个更适合您的需求:
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;
}
}
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
NameVirtualHost 127.0.0.1:8000
Listen 8000
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
map $sent_http_content_type $expires {
default off;
~css max;
~javascript max;
~image max;
~font-woff max;
~video max;
~zip max;
~txt max;
}
expires $expires;
server {
listen 80;
server_name exemple.com;
root /home/to/exemple.com;
index index.php index.html;
gzip on;
gzip_min_length 128;
gzip_http_version 1.1;
gzip_buffers 128 32k;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "msie6";
gzip_vary on;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
apt install libapache2-mod-php7.0
apt install libapache2-mod-php
a2enmod php7.0
<VirtualHost *:8000>
ServerName exemple.com
DocumentRoot /home/to/exemple.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
<Directory /home/to/exemple.com/>
php_admin_flag engine on
Options -ExecCGI -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
systemctl restart apache2
systemctl restart nginx