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.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!
恭喜你,環境配置成功了!
相關文章
- Windows下Scoop安裝、配置與使用WindowsOOP
- Windows10 下caffe-Windows安裝與配置Windows
- Redis安裝與配置(學習筆記一)Redis筆記
- jenkins安裝與配置學習Jenkins
- windows下Tomcat安裝配置WindowsTomcat
- RabbitMQ學習系列一:windows下安裝RabbitMQ服務MQWindows
- Windows下VisualSVN Server的安裝與配置方法(圖文)WindowsServer
- 本地windows搭建spark環境,安裝與詳細配置(jdk安裝與配置,scala安裝與配置,hadoop安裝與配置,spark安裝與配置)WindowsSparkJDKHadoop
- Linux & Windows 環境下 RabbitMQ 安裝與基本配置LinuxWindowsMQ
- Linux & Windows 環境下 Redis 安裝與基本配置LinuxWindowsRedis
- Windows平臺下安裝與配置MySQL9WindowsMySql
- Windows平臺下安裝與配置MySQL5.7WindowsMySql
- solr在windows下的安裝及配置SolrWindows
- Windows下Oracle的下載與安裝WindowsOracle
- Katalon Studio > 安裝與配置(Windows)Windows
- 【Mysql】Windows下安裝和配置MysqlMySqlWindows
- Ubuntu下 hadoop的安裝與配置UbuntuHadoop
- windows 下 MongoDB 的安裝與啟動WindowsMongoDB
- maven下載、安裝與配置Maven
- Linux下rsync安裝與配置Linux
- Windows10下JDK8的下載安裝與環境變數的配置WindowsJDK變數
- Git 學習之安裝配置Git
- windows下安裝MongoDB擴充套件和配置WindowsMongoDB套件
- windows下安裝jdk+tomcat+maven並配置WindowsJDKTomcatMaven
- (轉)Windows下安裝Docker, GitBash環境配置WindowsDockerGit
- 下載、安裝、配置 android-studio-2021.1.1.22-windowsAndroidWindows
- Qt學習第一篇(windows下安裝和程式碼規範)QTWindows
- 不用rustup,Windows下gnu版Rust安裝與開發環境配置RustWindows開發環境
- postgreSQL學習(一):在Linux下安裝postgreSQLSQLLinux
- CentOS 8.2下VNC安裝與配置CentOSVNC
- MySQL - 下載與安裝配置(Linux)MySqlLinux
- pycharm下載安裝與基本配置PyCharm
- CentOS 下多版本 PHP 的安裝與配置CentOSPHP
- CentOS6下mysql的安裝與配置CentOSMySql
- centos7 (阿里雲、linux) 單機spark的安裝與配置詳解(jdk安裝與配置,scala安裝與配置,hadoop安裝與配置,spark安裝與配置)CentOS阿里LinuxSparkJDKHadoop
- windows 下安裝Windows
- windows下pytorch的安裝WindowsPyTorch
- Oracle for Windows安裝和配置之一OracleWindows
- Anaconda(conda)在windows安裝與環境配置Windows