关于lnmp下 phalcon和tp框架下的nginx文件配置

时间:2023-03-09 15:19:34
关于lnmp下 phalcon和tp框架下的nginx文件配置

vim /etc/nginx/sites-available/default   进入修改目录

1.正常项目配置

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

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
root /var/www/php;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

#server_name www.wudi.com; #网站的域名

location / {
try_files $uri $uri/ =404;
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 10000;
}
}

2.tp框架配置

server {
listen 8081;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
root /var/www/tp5/public;

# Add index.php to the list if you are using PHP
index index.html index.htm index.php;

#server_name www.wudi.com; #网站的域名

location / {
#try_files $uri $uri/ =404;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 10000;
}
}

3.phalcon框架下配置

server {
listen 8082;
# server_name
root /var/www/daifang/public;
index index.php index.html index.htm;
charset utf-8;

location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}

location ~ \.php {
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

# location ~ /\.ht {
# deny all;
# }
}