[英]PHP app deploy Ubuntu 16.04 nginx apache setting
這是我嘗試部署一個小型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配置
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;
}
}
apache配置
PHP 7國防部
apt install libapache2-mod-php7.0
PHP5國防部
apt install libapache2-mod-php
包括例如php7.0 mod
a2enmod php7.0
VirtualHost配置apache
<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>
刪除apache2.conf中的NameVirtualHost 127.0.0.1:8000粘貼ServerName 127.0.0.1
systemctl restart apache2
systemctl restart nginx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.