php+nginx+mysql环境配置

来源:互联网 发布:软件项目标书 编辑:程序博客网 时间:2024/06/01 07:42

下载 RunHiddenConsole.exe,nginx,php,mysql,composer 中国镜像,

通过composer 生成lavarl项目;

1.php.ini设置

extension=php_openssl.dll

extension=php_mbstring.dll

2.建立 start_nginx_php.bat文件

@echo off
echo Starting PHP FastCGI...
RunHiddenConsole E:/PhpIntegration/php/php-cgi.exe -b 127.0.0.1:9000 -c E:/PhpIntegration/php/php.ini       
 
echo Starting Nginx...
RunHiddenConsole E:/PhpIntegration/nginx-1.10.3/nginx.exe -c  E:/PhpIntegration/nginx-1.10.3/conf/nginx.conf


echo Starting MySQL Server...
RunHiddenConsole C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe


3.建立 stop_nginx_php.bat文件

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


4.主要 nginx.config

 server {
        listen       80;    
server_name  localhost;
        client_max_body_size 30m;
#charset koi8-r;
#set $root_path 'E:/study/php/phpStudy/laravel5_backend/public'; 
#set $root_path 'E:/study/php/phpStudy/laravel55/public';
set $root_path 'E:/study/php/phpStudy/lumen/public';
        root $root_path;
        #access_log  logs/host.access.log  main;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {  
            rewrite ^/(.*)$ /index.php?_url=/$1;  
        } 
        location / {
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }


        #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           d:/www/nginx/html;
            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  /scripts$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {  
            root $root_path;  
        }  


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