Windows PHP发不环境安装
Windows Server 2003 R2可以安装PHP 5.6.x版本的PHP环境, Windows Server 2012 R2可以安装PHP 7.2.x版本的PHP环境, 因为不同Server版本的vc++环境不一样, 2003 R2安装VC++2012, 2012 R2安装VC++2015
下载PHP,下载Nginx,下载MySQL,下载VC++
PHP 5.6.36
PHP 7.2.6
Nginx 1.15.0
MySQL 5.7.22
VC++ 2012
VC++ 2015
xxfpm
PHP和Nginx和MySQL下载压缩包,解压到对应的安装目录, VC++下载对应服务器版本的对应版本,然后正常安装
PHP文件配置
- 复制php.ini-development为php.ini
- 更改php.ini,打开相关的扩展和配置
1 2 3 4 5
| extension=php_openssl.dll extension=php_pdo_mysql.dll extension=php_fileinfo.dll extension_dir = "./ext"
|
MySQL数据库安装
- 使用管理员打开cmd,切换到MySQL解压目录,运行mysqld.exe install
- 更改数据库配置,在MySQL解压目录下新建一个my.ini文件,添加相关配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| [client] socket=D:/lxxhd/mysql-5.7.22/mysql.sock [mysqld] datadir=D:/lxxhd/mysql-5.7.22/data socket=D:/lxxhd/mysql-5.7.22/mysql.sock user=mysql symbolic-links=0 slow_query_log = 1 slow_query_log_file = D:/lxxhd/mysql-5.7.22/mysql-slow.log long_query_time = 2 general_log = 1 general_log_file = D:/lxxhd/mysql-5.7.22/mysql-general.log server_id=101 log_bin=D:/lxxhd/mysql-5.7.22/mysql-bin.log binlog_format=ROW sync_binlog=1 expire_logs_days=7 log_error=D:/lxxhd/mysql-5.7.22/mysql.err character_set_server = utf8 transaction-isolation = READ-COMMITTED max_connections = 1000 log-queries-not-using-indexes log_throttle_queries_not_using_indexes = 10 innodb_strict_mode=1 innodb_file_format=Barracuda innodb_file_format_max=Barracuda innodb_read_io_threads=4 innodb_write_io_threads=8 innodb_io_capacity=1000 innodb_adaptive_flushing=1 innodb_flush_log_at_trx_commit=1 innodb_max_dirty_pages_pct=75 innodb_buffer_pool_dump_at_shutdown=1 innodb_buffer_pool_load_at_startup=1 innodb_flush_neighbors=1 innodb_log_file_size=1024M innodb_purge_threads=1 innodb_lock_wait_timeout=3 innodb_print_all_deadlocks=1 innodb_buffer_pool_size=4096M [mysqld_safe] log-error=D:/lxxhd/mysql-5.7.22/log/mysqld.log pid-file=D:/lxxhd/mysql-5.7.22/log/mysqld.pid
|
- 在MySQL解压目录的cmd命令行中init数据库,运行mysqld.exe –initialize-insecure命令
- 这个时候数据库的密码为’’,运行ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘YOUR_NEW_PASS’;命令更改密码
- 使用net start mysql启动服务
- 配置MySQL环境变量
Nginx服务安装和配置
- 解压安装Nginx
- 运行nginx.exe文件,然后通过tasklist /fi “imagename eq nginx.exe”命令查看nginx进程, 访问http://localhost查看nginx页面(注:需要注意访问端口的配置)
- 加入PHP配置文件,更改nginx.conf加入php关联配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| worker_processes 1; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 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; keepalive_timeout 65; server { listen 8080; server_name localhost; charset utf-8; access_log logs/lxxhd.access.log main; location / { root D:/lxxhd/www; index index.php index.html index.htm; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } }
|
1
| D:/lxxhd/php-5.6.36/php-cgi.exe -b 127.0.0.1:9000 -c D:/lxxhd/php-5.6.36/php.ini
|
安装xxfpm
编写bat脚本
下载RunHiddenConsole.exe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| # start.bat @ECHO off SET php_home=PHP安装目录 SET nginx_home=NGINX安装目录 REM 输出状态 ECHO Starting PHP FastCGI... RunHiddenConsole xxfpm "%php_home%php-cgi.exe -c %php_home%php.ini" -n 5 -i 127.0.0.1 -p 9000 ECHO Starting nginx... RunHiddenConsole %nginx_home%nginx.exe -p %nginx_home%
|
1 2 3 4 5 6 7 8
| # stop.bat @ECHO off ECHO Stopping nginx... TASKKILL /F /IM nginx.exe ECHO Stopping PHP FastCGI... TASKKILL /F /IM php-cgi.exe EXIT
|
start.bat和stop.bat和RunHiddenConsole.exe放在同一个目录下,使用start.bat启动服务
注:nginx的worker_processes要与cpu的数量一致
NGINX Laravel发布配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| worker_processes 32; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 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; keepalive_timeout 65; server { listen 8080; server_name localhost; client_max_body_size 100m; charset utf-8; root D:/lxxhd/www/lxxhd/public; access_log logs/lxxhd.access.log main; location / { try_files $uri $uri/ /index.php?$query_string; index index.php index.html index.htm; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } }
|
最后更新时间:
这里可以写作者留言,标签和 hexo 中所有变量及辅助函数等均可调用,示例:
http://yoursite.com/2018/06/21/windows-php-deploy-env/