Last active
February 11, 2024 14:10
-
-
Save eeskildsen/6fc10cdee86cc2bafa331e7fd4599cc6 to your computer and use it in GitHub Desktop.
Create a WordPress site with a SQLite database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creates a WordPress site with SQLite as the database. Should be cross platform. | |
param( | |
[Parameter(Mandatory)] | |
[string] | |
$SiteName | |
) | |
# Create a directory | |
Write-Host "Creating directory $SiteName." | |
New-Item $SiteName -ItemType Directory | |
Push-Location $SiteName | |
Write-Host "Created directory $SiteName." -ForegroundColor Green | |
# Download and extract WordPress | |
Write-Host 'Downloading WordPress.' | |
$ProgressPreference = 'SilentlyContinue' # Prevents PowerShell from showing a progress bar that significantly slows download speed | |
Invoke-WebRequest https://wordpress.org/latest.zip -OutFile latest.zip | |
Write-Host 'WordPress downloaded.' -ForegroundColor Green | |
Write-Host 'Extracting WordPress.' | |
Expand-Archive latest.zip | |
Move-Item latest\wordpress\* . | |
Remove-Item latest.zip | |
Remove-Item latest -Recurse -Force | |
Write-Host 'WordPress extracted.' -ForegroundColor Green | |
# Download and extract SQLite drop-in database replacement | |
Write-Host 'Downloading wp-sqlite-db.' | |
git clone https://github.com/aaemnnosttv/wp-sqlite-db --depth 1 | |
Write-Host 'wp-sqlite-db downloaded.' -ForegroundColor Green | |
Write-Host 'Copying wp-sqlite-db.' | |
Copy-Item .\wp-sqlite-db\src\db.php .\wp-content\ -Force | |
Remove-Item .\wp-sqlite-db -Recurse -Force | |
Write-Host 'wp-sqlite-db copied.' -ForegroundColor Green | |
# Configure wp-config.php (database setup errors out with SQLite for some reason) | |
Write-Host 'Configuring wp-config.php.' | |
Copy-Item .\wp-config-sample.php .\wp-config.php | |
(Get-Content .\wp-config.php | ForEach-Object { $_ -replace 'put your unique phrase here', (New-Guid) }) | Set-Content .\wp-config.php | |
Remove-Item .\wp-config-sample.php | |
Write-Host 'wp-config.php configured.' -ForegroundColor Green | |
Write-Host 'All done.' -ForegroundColor Green | |
Write-Host 'Uncomment `extension=pdo_sqlite` and `extension=openssl` in your php.ini if you haven''t already. You can find your php.ini location by running `php --ini`.' | |
Write-Host "Serve your new WordPress site via `cd $SiteName`, then `php -S 127.0.0.1:8080." | |
Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment