{"id":992,"date":"2013-01-27T14:26:23","date_gmt":"2013-01-27T14:26:23","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=992"},"modified":"2022-06-03T03:52:23","modified_gmt":"2022-06-03T08:52:23","slug":"script-install-wordpress-on-a-debianubuntu-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/script-install-wordpress-on-a-debianubuntu-vps\/","title":{"rendered":"Script: Install WordPress on a Debian\/Ubuntu VPS"},"content":{"rendered":"
Previously we explained how to install WordPress on a Debian VPS<\/a>. Also you can install WordPress on Debian<\/a> or Ubuntu VPS<\/a> in an easier way, using the script provided in this article. This script will create a MySQL database, will download and configure the latest WordPress version and create Apache virtual host for you automatically. All you need to do is to create a file on your WordPress VPS<\/a> with the content shown below, make the file executable, execute it and enter a few parameters.<\/p>\n <\/p>\n Create a new file and paste the script:<\/p>\n Make the script executable:<\/p>\n Execute the script:<\/p>\n For updates, you can also read our post on How to Install WordPress with Nginx on Debian 10<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" Previously we explained how to install WordPress on a Debian VPS. Also you can install WordPress on Debian or Ubuntu … <\/p>\n# nano wpinstall<\/pre>\n
#!\/bin\/bash\n#\n# Install WordPress on a Debian\/Ubuntu VPS\n#\n\n# Create MySQL database\nread -p \"Enter your MySQL root password: \" rootpass\nread -p \"Database name: \" dbname\nread -p \"Database username: \" dbuser\nread -p \"Enter a password for user $dbuser: \" userpass\necho \"CREATE DATABASE $dbname;\" | mysql -u root -p$rootpass\necho \"CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$userpass';\" | mysql -u root -p$rootpass\necho \"GRANT ALL PRIVILEGES ON $dbname.* TO '$dbuser'@'localhost';\" | mysql -u root -p$rootpass\necho \"FLUSH PRIVILEGES;\" | mysql -u root -p$rootpass\necho \"New MySQL database is successfully created\"\n\n# Download, unpack and configure WordPress\nread -r -p \"Enter your WordPress URL? [e.g. mywebsite.com]: \" wpURL\nwget -q -O - \"http:\/\/wordpress.org\/latest.tar.gz\" | tar -xzf - -C \/var\/www --transform s\/wordpress\/$wpURL\/\nchown www-data: -R \/var\/www\/$wpURL && cd \/var\/www\/$wpURL\ncp wp-config-sample.php wp-config.php\nchmod 640 wp-config.php\nmkdir uploads\nsed -i \"s\/database_name_here\/$dbname\/;s\/username_here\/$dbuser\/;s\/password_here\/$userpass\/\" wp-config.php\n\n# Create Apache virtual host\necho \"\nServerName $wpURL\nServerAlias www.$wpURL\nDocumentRoot \/var\/www\/$wpURL\nDirectoryIndex index.php\n\nOptions FollowSymLinks\nAllowOverride All\n\nErrorLog ${APACHE_LOG_DIR}\/error.log\nCustomLog ${APACHE_LOG_DIR}\/access.log combined\n\" > \/etc\/apache2\/sites-available\/$wpURL\n\n# Enable the site\na2ensite $wpURL\nservice apache2 restart\n\n# Output\nWPVER=$(grep \"wp_version = \" \/var\/www\/$wpURL\/wp-includes\/version.php |awk -F\\' '{print $2}')\necho -e \"\\nWordPress version $WPVER is successfully installed!\"\necho -en \"\\aPlease go to http:\/\/$wpURL and finish the installation\\n\"<\/pre>\n
# chmod +x wpinstall<\/pre>\n
# .\/wpinstall<\/pre>\n\n\n