配置 nginx.conf
# user www www;
pid tmp/dev-nginx.pid;
# This number should be at maxium the number of CPU on the server
worker_processes 2;
events {
# Number of connections per worker
worker_connections 4096;
}
http {
sendfile on;
include ./mime.types;
lua_package_path "./app/?.lua;./?.lua;/usr/local/lor/?.lua;;;;";
lua_package_cpath "./app/librarys/?.so;/usr/local/lor/?.so;;";
lua_code_cache on;
server {
# List port
listen 8888;
# Access log
access_log logs/dev-access.log;
# Error log
error_log logs/dev-error.log;
# this variable is for view render(lua-resty-template)
set $template_root '';
location /static {
alias ./app/static; #app/static;
}
# lor runtime
location / {
content_by_lua_file ./app/main.lua;
}
}
include ./vhost/*.conf;
}
在项目 conf
文件夹中建子目录 vhost
,新建文件 php.conf
:
server{
listen 80;
server_name _;
root /home/wwwroot/php.com;#网站的根目录
location / {
index index.html index.htm index.php;#域名下的默认访问文件
}
location ~ \.php$ {#所有以.php结尾的文件都交给php处理
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
这里 127.0.0.1:9000
是 php-fpm
官方原版默认端口,按需修改。