阅读更多
步骤一:在对应目录创建文件夹 例:/home/www/kelikexin
步骤二:/usr/local/nginx/conf/vhost 下创建nginx配置文件 ***.conf
步骤三:打开创建瞸nginx配置文件复制以下代码:
#limit_zone crawler $binary_remote_addr 10m;
#logo日志名称
log_format *** '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
#端口号,一般为80端口
listen 80;
#指定网址
server_name **;
#访问入口文件
index index.html index.htm index.php;
#访问文件所在文件夹
root /home/www/文件夹;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ .*\.php($|/) {
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME
/home/www/文件夹/$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
#logo日志
access_log /home/logs/***.log test.klkx.com;
}
第四步:重启nginx
注:重启ngnix报(nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
)错
解决办法:查看80端口是否被占用
命令:netstat -ntpl
强制停止占用80端口瞸应用
kill -9 nginx nginx参数必须是进程或任务 ID
重启nginx即可.