Skip to content

Instantly share code, notes, and snippets.

@BeKnowDo
Last active July 8, 2024 10:58
Show Gist options
  • Select an option

  • Save BeKnowDo/eda124eea1aba844f9eecfbcd6cc411a to your computer and use it in GitHub Desktop.

Select an option

Save BeKnowDo/eda124eea1aba844f9eecfbcd6cc411a to your computer and use it in GitHub Desktop.
Windows 10 sucks...but we can make it less sucky. This is how I setup local development for Win10

Install Chocolately

Install Nginx

  • Install via chocolately choco install nginx -y ** The -y argument is to skip any confirmation messages...just install it. It's fine ;)

Install PHP

  • Install via chocolately choco install php

Install MySQL

  • Install via chocolately choco install mysql

Install MySQL Workbench

  • Install via chocolately choco install mysql.workbench

Configuration Paths

Nginx Configuration Path
  • C:\tools\nginx-1.17.0\conf or whichever is the latest version installed
PHP Configuration Path
  • C:\tools\php72 or whichever is the latest version installed

PHP.ini Enabled Extensions

  • Make sure to enable the following extensions

extension=curl
extension=odbc
extension=pdo_mysql
extension=pdo_mysql

Create bat file in the same directory as your PHP Configuration Path.

We use this .bat file to run PHP-FPM. You can name this file anything you'd like, i.e.: start-php-fcgi.bat.
Copy the following into that file:

@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=C:\tools\php73\;%PATH%
C:\tools\php73\php-cgi.exe -b 127.0.0.1:9000

Download the following code snippet that will run PHP in the background without needing to have a console/terminal opened.

HiddenConsole

Read more on why we want this tool.

Now open a new terminal/prompt and run the following command c:\tools\php73\start-php-fcgi.bat


This will run the required PHP CGI on windows :)

Example Nginx Configuration

  • This is our default nginx configuration. I like to put all servers into a dedicated folder, e.g.: /servers
Default Configuration
# user  nobody;
worker_processes  1;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

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

    sendfile        on; 
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root   html;
        }
        
        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;
        }
    }

    include C:/nginx-1.17.3/conf/servers/*.conf;
}

Additional Server Example Configuration

server {
    listen 80;
    server_name  php.kanebridge;
    index index.php;
    error_log C:/nginx-1.17.3/php-test/error.log;
    access_log C:/nginx-1.17.3/php-test/access.log;
    root C:/web-projects/php-test;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
    }
}

Running all of this stuff :)

  • I use CMDer but you can use any terminal. I'd use cmder. It's less suckage.

Nginx

  • Nginx should be running at this point. You can check by visiting http://localhost in your browser of choice.
  • Next, let's add nginx to Windows' PATH variables. To do this, open "System Properties" and visit the "Advanced Tab" and click on "Environment Variables" on the bottom right of the window (http://drops.cavscout.us/TSdFDY).
  • Next, you'll need to find "Path" variable under "System variables" (http://drops.cavscout.us/vtP5bo) and enter the nginx path which is: C:\tools\nginx-1.17.0.
  • Click 'OK' and you should be all set to use nginx in your terminal.
  • You now have the following options to run in the terminal:
    • nginx -s stop fast shutdown
    • nginx -s quit graceful shutdown
    • nginx -s reload changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
    • nginx -s reopen re-opening log files
  • Next, you'll need to create an entry in Windows' hosts file which is located in C:\Windows\System32\drivers\etc.

Other Developer Applications

choco upgrade chocolatey

choco install vscode

choco install git

choco install smartgit

choco install vlc

choco install 7zip.install

Generating SSH Key

Windows 7 (how dare you)

To generate an SSH key in Windows 7, you'll need to download a console/terminal emulator that has SSH built-in. One of the most widely used emulators for Windows is either Cygwin or Cmder. Let's go with Cmder.

  • Download Cmder
  • Extract the zip file into your desired directory (I'd keep it at the root of your C: drive - i.e.: C:/Cmder)

This is a mandatory security step from GitHub.

  • Open PowerShell (as admin) and type the following command: ssh-keygen.exe

    You'll be prompted several times. There is no need to do anything other than hitting the enter key until you see ASCII art (a picture of sorts) in the terminal (powershell in this case).

(Make sure vscode is installed)

  • Copy the path generated by ssh-keygen and open it with vscode code C:\Users\YOUR_USER_PROFILE_NAME\.ssh\id_rsa.pub.

    Open the file named id_rsa.pub copy the value from the file.

    Hint: The ssh key should begin with: ssh-rsa

  • Log into https://github.com/settings/key and click "New SSH Key".

  • Paste your rsa key and click submit/save.

Now you are able to successfully clone any respository from GitHub.

Cloning the Kanebridge repository (source code)

Please make sure you're in the target directory you want the repository to be cloned into: i.e.: C:/web-projects (this can be any directory you wish.

git clone [email protected]:kanebridge-corp/kanebridge.com.git

Attunity Connection String Example

$connection_string = 'Driver={Attunity Connect Driver};BindUrl=attconnect://192.168.0.168:5330/Navigator;DefTdpName=KANERMS;OneTdpMode=1;misc/language=enus;queryProcessor/noThreads=true;debug/logFile=ODBC_MYDSN_%p.log;';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment