1、登录Xshell,输入ps -ef | grep nginx
查看nginx安装目录和nginx配置文件目录:

image.png
2、nginx.conf引入配置文件,配置文件如下:
http {
#代码
#底部引入2018qpl目录下的配置文件
include 2018qpl/*.conf;
}
host配置文件(端口占用时重启nginx会报错,尽量使用不常用的端口号):
server {
listen 8090; #端口号
server_name 192.168.1.243; #主机名
index index.php index.html index.htm;
root /usr/share/nginx/html/2018qpl/qpl;
error_page 404 /404.html; # 错误页面
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+?\.php)(/.+)$") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
location /ngx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
error_log /usr/share/nginx/html/2018qpl/qpl/qpl_8090error.log;
access_log /usr/share/nginx/html/2018qpl/qpl/qpl_8090access.log main;
}
端口占用报错:

image.png
3、切换到nginx安装目录执行代码nginx重启:./nginx -s reload
,然后浏览器输入http://192.168.1.243:8090/
就可以访问了!

image.png
网友评论