Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitToTheNew committed Aug 20, 2024
1 parent 02a0f4b commit db16a5c
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/ttn-windows-toolkit.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
`` Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down
8 changes: 8 additions & 0 deletions utility/EnableIIS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Enable IIS ServerRole and Feature on Windows Server or Windows Client
If ((Get-CimInstance Win32_OperatingSystem).ProductType -eq 1) {
# For Windows Client
Enable-WindowsOptionalFeature -FeatureName IIS-WebServerRole,IIS-WebServer,IIS-CommonHttpFeatures,IIS-StaticContent,IIS-DefaultDocument,IIS-DirectoryBrowsing,IIS-HttpErrors,IIS-ApplicationDevelopment,IIS-CGI,IIS-HealthAndDiagnostics,IIS-HttpLogging,IIS-LoggingLibraries,IIS-RequestMonitor,IIS-Security,IIS-RequestFiltering,IIS-Performance,IIS-HttpCompressionStatic,IIS-WebServerManagementTools,IIS-ManagementConsole,IIS-ManagementService,WAS-WindowsActivationService,WAS-ProcessModel,WAS-NetFxEnvironment,WAS-ConfigurationAPI,NetFx3 -Online -All -Source D:\Sources\sxs | Out-Null
} Else {
# For Windows Server
Install-WindowsFeature Web-Server,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-CGI,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Security,Web-Filtering,Web-Performance,Web-Stat-Compression,Web-Mgmt-Tools,Web-Mgmt-Service,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Net-Framework-Core -IncludeManagementTools | Out-Null
}
11 changes: 11 additions & 0 deletions utility/EnablePHPForIIS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Adding Index.php in default documents

add-webconfigurationproperty /system.webServer/defaultDocument -name files -value @{value="index.php"}

#Install Module for FastCGI
New-WebHandler -Name PHPFASTCGI -PATH "*.php" -Verb "*" -Modules "FastCgiModule" -ScriptProcessor "C:\PHP\php-cgi.exe" -ResourceType "Either"

Add-NTFSAccess C:\PHP\Upload IUSR Modify
Add-NTFSAccess C:\PHP\Upload IIS_IUSRS Modify

"Done."
26 changes: 26 additions & 0 deletions utility/MySQL8.0.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Install MySQL-8.0.
Invoke-WebRequest "https://downloads.mysql.com/archives/get/p/25/file/mysql-installer-web-community-8.0.37.0.msi" -OutFile "mysql_8.0.msi"
Start-Process "msiexec.exe" "/i mysql_8.0.msi /qn" -Wait

# Install MySQL as a Windows service
mysqld --install

# Start the MySQL service
Start-Service MySQL

# Generate random passwords for 'root' and 'WordPress' accounts
Add-Type -AssemblyName System.Web
$MYSQL_ROOT_PWD = [System.Web.Security.Membership]::GeneratePassword(18,3)
$MYSQL_WORD_PWD = [System.Web.Security.Membership]::GeneratePassword(18,3)

# Create a MySQL initialisation script
Set-Content $MYSQL_INIT "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PWD';"
Add-Content $MYSQL_INIT "CREATE DATABASE wordpress;"
Add-Content $MYSQL_INIT "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY '$MYSQL_WORD_PWD';"
Add-Content $MYSQL_INIT "GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';"

# Execute the MySQL initialisation script
mysql --user=root --execute="source $MYSQL_INIT"

# Delete the MySQL initialisation script
Remove-Item $MYSQL_INIT
17 changes: 17 additions & 0 deletions utility/PHPManger&PHP-7.2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<#
=================================== PHP 7.2 ====================================
#>

# Download and install PHP
"`r`nPHP 7.2 ..."
" - Downloading"
Install-Module -Name PhpManager -Repository PSGallery -Force
Install-Php -Version 7.2 -Architecture x64 -ThreadSafe 0 -Path C:\PHP -TimeZone UTC -Force
"Done."

Configure various PHP settings
Set-PhpIniKey date.timezone UTC C:\PHP
Set-PhpIniKey upload_max_filesize 20M C:\PHP
"Done."

"Done."
7 changes: 7 additions & 0 deletions utility/RemoteManagementService.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Enable Remote Management Service
" - Enabling Remote Management"
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\WebManagement\Server EnableRemoteManagement 1
Set-Service WMSVC -StartupType Automatic
Start-Service WMSVC

"Done."
7 changes: 7 additions & 0 deletions utility/RewriteURL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Download and install the "URL Rewrite 2.0" Extension for IIS
"`r`nURL Rewrite 2.0 Extension for IIS ..."
" - Downloading"
Invoke-WebRequest "https://download.microsoft.com/download/D/8/1/D81E5DD6-1ABB-46B0-9B4B-21894E18B77F/rewrite_x86_en-US.msi" -OutFile "rewrite_amd64.msi"
" - Installing"
Start-Process "msiexec.exe" "/i rewrite_amd64.msi /qn" -Wait
"Done."
3 changes: 3 additions & 0 deletions utility/SecurityNTFS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
#Enable NTFS Security Module
Install-Module -Name NTFSSecurity -RequiredVersion 4.2.4
5 changes: 5 additions & 0 deletions utility/VisualC++.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Install Visual C++
Invoke-WebRequest "https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe" -OutFile "vc_redist_2013_x64.exe"
.\vc_redist_2013_x64.exe /Q
Invoke-WebRequest "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" -OutFile "vc_redist_2015_x64.exe"
.\vc_redist_2015_x64.exe /Q
18 changes: 18 additions & 0 deletions utility/WinCache-2.0.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Download and install WinCache
"`r`nWinCache 2.0 ..."
" - Downloading"
Invoke-WebRequest "https://windows.php.net/downloads/pecl/releases/wincache/2.0.0.8/php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip" -OutFile "php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip"
" - Expanding"
Expand-Archive $env:USERPROFILE\Downloads\php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip $env:USERPROFILE\Downloads\wincache\
" - Installing"
Copy-Item "wincache\php_wincache.dll" "C:\PHP\\ext\php_wincache.dll"

Enabling Mysqliextensions
Enable-PhpExtension mysqli C:\PHP

Enabling PHP-Wincache Extention
" - Removing temporary files"
Enable-PhpExtension wincache C:\PHP

Remove-Item "wincache" -Recurse -Force
"Done."
48 changes: 48 additions & 0 deletions utility/WordPressInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<#
================================== WordPress ===================================
#>

# Set temporary variables to be used during the WordPress installation
$IIS_PATH = "C:\inetpub"
$WORDPRESS_PATH = "$IIS_PATH\wordpress"
$WORDPRESS_URL = "https://wordpress.org/latest.zip"
$WORDPRESS_ZIP = "wordpress.zip"

# Download and install WordPress
"`r`nWordPress ..."
" - Downloading"
Invoke-WebRequest "$WORDPRESS_URL" -OutFile "$WORDPRESS_ZIP"
" - Expanding"
Expand-Archive "$WORDPRESS_ZIP" "$IIS_PATH"

# Grant the IIS_IUSRS and IUSR accounts Modify rights to the WordPress directory
" - Appying NTFS Permissions (IIS_IUSRS)"
Add-NTFSAccess "$WORDPRESS_PATH" IIS_IUSRS Modify
" - Appying NTFS Permissions (IUSR)"
Add-NTFSAccess "$WORDPRESS_PATH" IUSR Modify

# Create a new Internet Information Services application pool for WordPress
" - Creating Application Pool"
$WebAppPool = New-WebAppPool "WordPress"
$WebAppPool.managedPipelineMode = "Classic"
$WebAppPool.managedRuntimeVersion = ""
$WebAppPool | Set-Item

# Create a new Internet Information Services website for WordPress
" - Creating WebSite"
New-Website "WordPress" -ApplicationPool "WordPress" -PhysicalPath "$WORDPRESS_PATH" | Out-Null

# Remove the “Default Web Site” and start the new “WordPress” website
" - Activating WebSite"
Remove-Website "Default Web Site"
Start-Website "WordPress"

"Done."

<#
================================================================================
#>

"`r`nInstallation Complete!`r`n"
$IPADDRESS = (Get-NetIPAddress | ? {($_.AddressFamily -eq "IPv4") -and ($_.IPAddress -ne "127.0.0.1")}).IPAddress
"`r`nConnect your web browser to http://$IPADDRESS/ to complete this WordPress`r`ninstallation.`r`n"
185 changes: 185 additions & 0 deletions wordpress/wordpress.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
cd ~\Downloads

<#
======================== Internet Information Services =========================
#>

"`r`nInternet Information Server ..."
" - Installing Features"
If ((Get-CimInstance Win32_OperatingSystem).ProductType -eq 1) {

# Windows Client

Enable-WindowsOptionalFeature -FeatureName `
IIS-WebServerRole,IIS-WebServer,IIS-CommonHttpFeatures,IIS-StaticContent, `
IIS-DefaultDocument,IIS-DirectoryBrowsing,IIS-HttpErrors, `
IIS-ApplicationDevelopment,IIS-CGI,IIS-HealthAndDiagnostics, `
IIS-HttpLogging,IIS-LoggingLibraries,IIS-RequestMonitor,IIS-Security, `
IIS-RequestFiltering,IIS-Performance,IIS-HttpCompressionStatic, `
IIS-WebServerManagementTools,IIS-ManagementConsole,IIS-ManagementService, `
WAS-WindowsActivationService,WAS-ProcessModel,WAS-NetFxEnvironment, `
WAS-ConfigurationAPI,NetFx3 -Online -All -Source D:\Sources\sxs | Out-Null
}
Else {

# Windows Server

Install-WindowsFeature `
Web-Server,Web-Common-Http,Web-Static-Content,Web-Default-Doc, `
Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-CGI,Web-Health, `
Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Security, `
Web-Filtering,Web-Performance,Web-Stat-Compression,Web-Mgmt-Tools, `
Web-Mgmt-Service,WAS,WAS-Process-Model,WAS-NET-Environment, `
WAS-Config-APIs,Net-Framework-Core -IncludeManagementTools | Out-Null
}

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

# Enable Remote Management Service
" - Enabling Remote Management"
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\WebManagement\Server EnableRemoteManagement 1
Set-Service WMSVC -StartupType Automatic
Start-Service WMSVC

"Done."

# Download and install the "URL Rewrite 2.0" Extension for IIS
"`r`nURL Rewrite 2.0 Extension for IIS ..."
" - Downloading"
Invoke-WebRequest "https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi" -OutFile "rewrite_amd64.msi"
" - Installing"
Start-Process "msiexec.exe" "/i rewrite_amd64.msi /qn" -Wait
"Done."

<#
==================== File System Security PowerShell Module ====================
#>

# Download and extract the "File System Security PowerShell Module"
"`r`nFile System Security PowerShell Module ..."
Install-Module -Name NTFSSecurity -RequiredVersion 4.2.4 -Repository PSGallery -Force
"Done."

<#
===================== Visual C++ Redistributable Packages ======================
#>

# Download and install the Visual C++ 2013 Redistributable (required for MySQL)
"`r`nVisual C++ 2013 Redistributable ..."
" - Downloading"
Invoke-WebRequest "https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe" -OutFile "vc_redist_2013_x64.exe"
" - Installing"
.\vc_redist_2013_x64.exe /Q
"Done."

# Download and install the Visual C++ 2015 Redistributable (required for PHP 7.x)
"`r`nVisual C++ 2015 Redistributable ..."
" - Downloading"
Invoke-WebRequest "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" -OutFile "vc_redist_2015_x64.exe"
" - Installing"
.\vc_redist_2015_x64.exe /Q
"Done."


<#
=================================== PHP 7.2 ====================================
#>

# Download and install PHP
"`r`nPHP 7.2 ..."
" - Downloading"
Install-Module -Name PhpManager -Repository PSGallery -Force
Install-Php -Version 7.2 -Architecture x64 -ThreadSafe 0 -Path C:\PHP -TimeZone UTC -Force
"Done."

Configure various PHP settings
Set-PhpIniKey date.timezone UTC C:\PHP
Set-PhpIniKey upload_max_filesize 20M C:\PHP
"Done."

"Done."

# Download and install WinCache
"`r`nWinCache 2.0 ..."
" - Downloading"
Invoke-WebRequest "https://windows.php.net/downloads/pecl/releases/wincache/2.0.0.8/php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip" -OutFile "php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip"
" - Expanding"
Expand-Archive $env:USERPROFILE\Downloads\php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip $env:USERPROFILE\Downloads\wincache\
" - Installing"
Copy-Item "wincache\php_wincache.dll" "C:\PHP\\ext\php_wincache.dll"

Enabling Mysqliextensions
Enable-PhpExtension mysqli C:\PHP

Enabling PHP-Wincache Extention
" - Removing temporary files"
Enable-PhpExtension wincache C:\PHP

Remove-Item "wincache" -Recurse -Force
"Done."




"`r`nConfigure PHP with IIS ..."

# Adding Index.php in default documents

add-webconfigurationproperty /system.webServer/defaultDocument -name files -value @{value="index.php"}

#Install Module for FastCGI
New-WebHandler -Name PHPFASTCGI -PATH "*.php" -Verb "*" -Modules "FastCgiModule" -ScriptProcessor "C:\PHP\php-cgi.exe" -ResourceType "Either"

Add-NTFSAccess C:\PHP\Upload IUSR Modify
Add-NTFSAccess C:\PHP\Upload IIS_IUSRS Modify

"Done."

<#
================================== WordPress ===================================
#>

# Set temporary variables to be used during the WordPress installation
$IIS_PATH = "C:\inetpub"
$WORDPRESS_PATH = "$IIS_PATH\wordpress"
$WORDPRESS_URL = "https://wordpress.org/latest.zip"
$WORDPRESS_ZIP = "wordpress.zip"

# Download and install WordPress
"`r`nWordPress ..."
" - Downloading"
Invoke-WebRequest "$WORDPRESS_URL" -OutFile "$WORDPRESS_ZIP"
" - Expanding"
Expand-Archive "$WORDPRESS_ZIP" "$IIS_PATH"

# Grant the IIS_IUSRS and IUSR accounts Modify rights to the WordPress directory
" - Appying NTFS Permissions (IIS_IUSRS)"
Add-NTFSAccess "$WORDPRESS_PATH" IIS_IUSRS Modify
" - Appying NTFS Permissions (IUSR)"
Add-NTFSAccess "$WORDPRESS_PATH" IUSR Modify

# Create a new Internet Information Services application pool for WordPress
" - Creating Application Pool"
$WebAppPool = New-WebAppPool "WordPress"
$WebAppPool.managedPipelineMode = "Classic"
$WebAppPool.managedRuntimeVersion = ""
$WebAppPool | Set-Item

# Create a new Internet Information Services website for WordPress
" - Creating WebSite"
New-Website "WordPress" -ApplicationPool "WordPress" -PhysicalPath "$WORDPRESS_PATH" | Out-Null

# Remove the “Default Web Site” and start the new “WordPress” website
" - Activating WebSite"
Remove-Website "Default Web Site"
Start-Website "WordPress"

"Done."

<#
================================================================================
#>

"`r`nInstallation Complete!`r`n"
$IPADDRESS = (Get-NetIPAddress | ? {($_.AddressFamily -eq "IPv4") -and ($_.IPAddress -ne "127.0.0.1")}).IPAddress
"`r`nConnect your web browser to http://$IPADDRESS/ to complete this WordPress`r`ninstallation.`r`n"

0 comments on commit db16a5c

Please sign in to comment.