Windows下Nginx+PHP+ThinkPHP的安装与配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/amyacker/article/details/88787643

下载:

1.解压PHP5.6
在这里插入图片描述
2.解压Nginx
在这里插入图片描述
3.解压ThinkPHP:
在这里插入图片描述
4.修改PHP文件夹目录下的php.ini-development文件,把“-development”去掉就可以,文件内容先不做任何修改。

5.修改Nginx配置文件nginx.conf

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   D:\php\xxx\public;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
		
		location ~ .*\.php.* {
			root           D:\php\xxx\public;
			fastcgi_pass	127.0.0.1:9000;
			fastcgi_index	index.php;
			include	fastcgi.conf;
			set	$real_script_name	$fastcgi_script_name;
			fastcgi_param	SCRIPT_FILENAME	$document_root$fastcgi_script_name;
			fastcgi_param	SCRIPT_NAME		$real_script_name;
			fastcgi_param	PATH_INFO		$path_info;
			if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
				set	$real_script_name	$1;
				set	$path_info	$2;
			}
		}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

6.下载RunHiddenConsole.exe和配置文件
在这里插入图片描述
start_nginx.bat:

@echo off
set PHP_FCGI_MAX_REQUESTS=1000
echo Starting PHP FastCGI...
RunHiddenConsole D:\php\php-5.6.40-Win32-VC11-x64\php-cgi.exe -b 127.0.0.1:9000 -c D:\php\php-5.6.40-Win32-VC11-x64\php.ini 
echo Starting nginx...
RunHiddenConsole D:\php\nginx-1.15.9\nginx.exe
pause

stop_nginx.bat:

@echo off
echo Stopping nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

7.双击RunHiddenConsole.exe

8.打开浏览器,输入“http://localhost/index.php”

完成!!

  • 常见问题:

1.开启GD库:找到php文件夹下面的php.ini文件,把extension=php_gd2.dll前面的;去掉
在这里插入图片描述
2.curl_init扩展:把extension=php_curl.dll前面的;去掉
在这里插入图片描述
3.安装mysqli扩展:把extension=php_mysqli.dll前面的;去掉
在这里插入图片描述
4.更改PHP扩展位置的目录路径:extension_dir=“ext” 默认是C盘下的,更改成php文件夹下面的ext文件夹
在这里插入图片描述
5.could not find driver错误:把extension=php_pdo_mysql.dll前面的;去掉
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/amyacker/article/details/88787643