ThinkPHP学习(一) Windows下Nginx+PHP5+ThinkPHP_3.2.1的安装与配置

简介: 工具原料: Nginx153: 网盘下载地址:http://pan.baidu.com/s/1qWNgLf2 php-5.3.28-nts-Win32-VC9-x86 网盘下载地址:http://pan.

工具原料:

Nginx153:

网盘下载地址:http://pan.baidu.com/s/1qWNgLf2

php-5.3.28-nts-Win32-VC9-x86

网盘下载地址:http://pan.baidu.com/s/1pdukY

ThinkPHP_3.2.1

网盘下载地址:http://pan.baidu.com/s/1pJlpfuj

RunHiddenConsole是一个用来隐藏 DOS窗口的小程序

网盘下载地址:http://pan.baidu.com/s/1gd7kApP

开始安装,其实就是解压文件:

解压Nginx到“F:\Nginx153”;


解压RunHiddenConsole到“F:\Nginx153”;

解压PHP5到“F:\PHP\php5328Win32”;


解压ThinkPHP到“F:\PHP”;


修改PHP配置文件

修改“F:\PHP\php5328Win32”目录下的文件“php.ini-development”的文件名,把“-development”去掉就可以,文件内容先不做任何修改。

修改Nginx配置文件

用文本编辑器,本人使用Notepad++打开“F:\Nginx153\conf”目录下的“Nginx.conf”文件,

配置文件内容如下,重点位置用中文简单注释了一下:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80; #//端口号
        server_name  localhost; #//域名,主机头值

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   F:\\www\\html; #//站点根目录
            index  index.html index.htm index.php; #//默认页
        }

        #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;
        }

        # 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           F:\\PHP;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
		
		#ThinkPHP配置
		location ~ .*\.php.* {
			root           F:\\PHP; #//ThinkPHP框架文件位置
			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;
			}
		}

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


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

创建启动服务批处理(.bat)文件,文件名“start_nginx.bat”,文件内容如下:

@echo off
echo Starting PHP FastCGI...
RunHiddenConsole ../php/php5328Win32/php-cgi.exe -b 127.0.0.1:9000 -c ../php/php5328Win32/php.ini
echo Starting nginx...
nginx.exe

pause

创建停止服务批处理(.bat)文件,文件名“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

见证奇迹的时刻:

双击“start_nginx.bat”启动服务,会打开一个DOS窗口,最小化或关闭即可;

打开浏览器,在地址栏输入“http://localhost/index.php”,回车,看到几个大字了吗?

欢迎使用ThinkPHP

恭喜你,环境配置成功了!

下一篇:ThinkPHP学习(二)理清ThinkPHP的目录结构及访问规则,创建第一个控制器

目录
相关文章
|
20天前
|
应用服务中间件 PHP nginx
今日小结通过aliyun的本地容器镜像部署我的nginx和php环境
简介: 本教程介绍如何基于 Dragonwell 的 Ubuntu 镜像创建一个运行 Nginx 的 Docker 容器。首先从阿里云容器镜像服务拉取基础镜像,然后编写 Dockerfile 确保 Nginx 作为主进程运行,并暴露 80 端口。最后,在包含 Dockerfile 的目录下构建自定义镜像并启动容器,确保 Nginx 在前台运行,避免容器启动后立即退出。通过 `docker build` 和 `docker run` 命令完成整个流程。
95 24
今日小结通过aliyun的本地容器镜像部署我的nginx和php环境
|
7天前
|
应用服务中间件 PHP nginx
当你的nginx服务器和php服务器不在一起的时候,这个nginx 的root目录问题
两个服务器的网站代码目录需要对齐,docker容器里面也是一样
|
1月前
|
存储 Cloud Native Java
Windows下Minio的安装以及基本使用
MinIO 是一个开源的云原生分布式对象存储系统,兼容亚马逊S3接口,适合存储大容量非结构化数据。本文介绍Windows下MinIO的安装与基本使用:通过以上步骤,您可以在Windows环境中成功安装并使用MinIO。
263 17
|
2月前
|
关系型数据库 MySQL 数据库
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
在这一章节,主要介绍两个部分,数据库相关概念及MySQL数据库的介绍、下载、安装、启动及连接。接着,详细描述了MySQL 8.0的版本选择与下载,推荐使用社区版(免费)。安装过程包括自定义安装路径、配置环境变量、启动和停止服务、以及客户端连接测试。此外,还提供了在同一台电脑上安装多个MySQL版本的方法及卸载步骤。最后,解释了关系型数据库(RDBMS)的特点,即基于二维表存储数据,使用SQL语言进行操作,格式统一且便于维护。通过具体的结构图展示了MySQL的数据模型,说明了数据库服务器、数据库、表和记录之间的层次关系。
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
|
2月前
|
安全 关系型数据库 MySQL
Windows Server 安装 MySQL 8.0 详细指南
安装 MySQL 需要谨慎,特别注意安全配置和权限管理。根据实际业务需求调整配置,确保数据库的性能和安全。
302 9
|
2月前
|
机器学习/深度学习 并行计算 异构计算
WINDOWS安装eiseg遇到的问题和解决方法
通过本文的详细步骤和问题解决方法,希望能帮助你顺利在 Windows 系统上安装和运行 EISeg。
143 2
|
3月前
|
网络安全 Windows
Windows server 2012R2系统安装远程桌面服务后无法多用户同时登录是什么原因?
【11月更文挑战第15天】本文介绍了在Windows Server 2012 R2中遇到的多用户无法同时登录远程桌面的问题及其解决方法,包括许可模式限制、组策略配置问题、远程桌面服务配置错误以及网络和防火墙问题四个方面的原因分析及对应的解决方案。
239 4
|
3月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
165 4
|
3月前
|
Dart 搜索推荐 IDE
Windows下Zed编辑器配置Dart环境
本文介绍了Dart编程语言及其主要框架Flutter的优势,并推荐使用轻量级编辑器Zed进行Dart开发。详细步骤包括Dart环境的安装与配置,Zed编辑器的安装与个性化设置,以及如何在Zed中编写并运行Dart的HelloWorld程序。通过自定义任务实现Dart文件的快速运行,提高了开发效率。
|
3月前
|
监控 安全 网络安全
Windows Server管理:配置与管理技巧
Windows Server管理:配置与管理技巧
156 3