-
-
Save bgallagh3r/2853221 to your computer and use it in GitHub Desktop.
#!/bin/bash -e | |
clear | |
echo "============================================" | |
echo "WordPress Install Script" | |
echo "============================================" | |
echo "Database Name: " | |
read -e dbname | |
echo "Database User: " | |
read -e dbuser | |
echo "Database Password: " | |
read -s dbpass | |
echo "run install? (y/n)" | |
read -e run | |
if [ "$run" == n ] ; then | |
exit | |
else | |
echo "============================================" | |
echo "A robot is now installing WordPress for you." | |
echo "============================================" | |
#download wordpress | |
curl -O https://wordpress.org/latest.tar.gz | |
#unzip wordpress | |
tar -zxvf latest.tar.gz | |
#change dir to wordpress | |
cd wordpress | |
#copy file to parent dir | |
cp -rf . .. | |
#move back to parent dir | |
cd .. | |
#remove files from wordpress folder | |
rm -R wordpress | |
#create wp config | |
cp wp-config-sample.php wp-config.php | |
#set database details with perl find and replace | |
perl -pi -e "s/database_name_here/$dbname/g" wp-config.php | |
perl -pi -e "s/username_here/$dbuser/g" wp-config.php | |
perl -pi -e "s/password_here/$dbpass/g" wp-config.php | |
#set WP salts | |
perl -i -pe' | |
BEGIN { | |
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9); | |
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|"; | |
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 } | |
} | |
s/put your unique phrase here/salt()/ge | |
' wp-config.php | |
#create uploads folder and set permissions | |
mkdir wp-content/uploads | |
chmod 775 wp-content/uploads | |
echo "Cleaning..." | |
#remove zip file | |
rm latest.tar.gz | |
#remove bash script | |
rm wp.sh | |
echo "=========================" | |
echo "Installation is complete." | |
echo "=========================" | |
fi |
Another installer for Shell perspective: https://github.com/cconversion/wp-installer
Inspired by, not forked from, this here @bgallagh3r gist.
Here is High Traffic wordpress server configuration bash script
https://github.com/bajpangosh/High-Traffic-wordpress-server-configuration
Wow, this Gist is still at the top of Google for "WordPress installer script" after 5+ years...
A simpler way to generate the salts via OpenSSL (albeit slightly less secure, but less chance of conflict due to symbols):
sed -i "s/put your unique phrase here/$(openssl rand -hex 48)/g"
Please check out SlickStack (any feedback appreciated):
Great gist :). Inspired me to fork it and modify it by adding support for wp-cli
https://gist.github.com/rjekic/2d04423bd167f8e7afd26f8982609378
Hi,
I am new to Perl and I want to change the table prefix as well.
Can you please tell me, how can I change the table prefix?
Worked like a charm and quickest installation of WordPress I have achieved so far. Thanks
Simple, direct, and reliable
Great work. Thanks!
I took this a step further by allowing it to configure my nginx server block. See here:
I wish there was something this simple for bind9 as well haha
Add this to your
~/.bashrc
alias wpinstall="curl -L -o 'wp.sh' https://gist.githubusercontent.com/bgallagh3r/2853221/raw/f3e2f2fa3048bbeb6d35799af068965bc5fd9b26/wp.sh && bash wp.sh"
thensource ~/.bashrc
Go into a dir you want to install WP in and just type wpinstall It's that easy!Update:
I've updated the URL to the gist in this comment, WP changed the latest.tar.gz to use HTTPS (finally) as such trying to grab a copy from http::// broke the scriptUpdate: July 8 2015
I've modified the script to add the salts automatically now thanks to @emirpprime's fork.
the new command should bealias wpinstall="curl -L -o 'wp.sh' https://gist.githubusercontent.com/bgallagh3r/2853221/raw/eb5070c1a4f06dc106847f2e53f1b207f8ec7cad/wp.sh && bash wp.sh"
Note that my script does NOT create the MySQL database for you as I currently use WHM/cPanel on our server to manage databases. If you want that functionality please use @emirpprime's fork here: https://gist.github.com/emirpprime/37ef1f355ec5a7ecbb8f.
I think the link above for @emirpprime's fork is broken. A google search suggest that he has changed his github handle?
I think the new link is: https://gist.github.com/phlbnks/37ef1f355ec5a7ecbb8f
Hi pal! I think you must add a database host URL to the script. Usually, it's localhost in wp-config.php and not work for me.
Hi, another updated version. This one where can create the database and asks to use if it already exists.
https://gist.github.com/FeChagas/54b0cdf354b197dc8e417357d7687e8b