Skip to content

Instantly share code, notes, and snippets.

@Niteshvgupta
Last active February 19, 2016 16:56
Show Gist options
  • Save Niteshvgupta/1b54462000ec8a9a3605 to your computer and use it in GitHub Desktop.
Save Niteshvgupta/1b54462000ec8a9a3605 to your computer and use it in GitHub Desktop.
wp-lemp
echo -n "Domain Name: "
read dmn
echo -n "Mysql Root Password: "
read -s mrp
echo -n "Database Name: "
read dbn
echo -n "Database User: "
read dbu
echo -n "Database Password: "
read -s dbp
echo "Are you sure you want to run this install? (y/n)"
read -e run
if [ "$run" != y ] ; then
exit
fi
sudo apt-get update
sudo apt-get install mysql-server php5-mysql
sudo mysql_install_db
mysql -e "UPDATE mysql.user SET Password = PASSWORD('$mrp') WHERE User = 'root'"
mysql -e "DROP USER ''@'localhost'"
mysql -e "DROP USER ''@'$(hostname)'"
mysql -e "DROP DATABASE test"
mysql -e "CREATE DATABASE $dbn;"
mysql -e "GRANT ALL PRIVILEGES ON $dbn.* TO '$dbu'@'localhost' IDENTIFIED BY '$dbp'"
mysql -e "FLUSH PRIVILEGES"
sudo apt-get install nginx
sudo service nginx start
sudo apt-get install php5-fpm
perl -pi -e 's|127.0.0.1:9000|/var/run/php5-fpm.sock|g' /etc/php5/fpm/pool.d/www.conf
sudo service php5-fpm restart
echo 'Configuring nginx...'
perl -pi -e 's|index index.html|index index.php index.html|g' /etc/nginx/sites-available/default
perl -pi -e "s|localhost|$dmn|g" /etc/nginx/sites-available/default
perl -pi -e 's|usr/share/nginx/html|var/www|g' /etc/nginx/sites-available/default
text=$(cat << EOS
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
EOS
)
perl -pi -e 's|location /|location ~ \.php$|g' /etc/nginx/sites-available/default
perl -0777 -pi -e "s|try_files \$uri \$uri/ /index.html;|$text|g" /etc/nginx/sites-available/default
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/$dmn
ln -s /etc/nginx/sites-available/$dmn /etc/nginx/sites-enabled/$dmn
sudo service nginx restart
cd /var/www
curl -O https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
cd wordpress
cp -rf . ..
cd ..
rm -R wordpress
cp wp-config-sample.php wp-config.php
perl -pi -e "s|database_name_here|$dbn|g" wp-config.php
perl -pi -e "s|username_here|$dbu|g" wp-config.php
perl -pi -e "s|password_here|$dbp|g" wp-config.php
mkdir wp-content/uploads
chmod 777 wp-content uploads
rm latest.tar.gz
rm wp-lemp.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment