Installing Web Server and WordPress via a BASH script (Rasbperry Pi)

Imagine this scenario; you have several Raspberry Pi computers and want to install the various packages (Apache, PHP, MySQL, WordPress) needed to make them web servers. This might be because you have a Code Club lesson where you want students to interact more with how web servers work, or if you are rebuilding a Raspberry Pi.

You could follow instructions on building a LAMP Web Server manually OR you could use a BASH script and let the various installs happen without any interaction, which could be set to run via a CRON job to carry out the install at a certain time.

#!/bin/bash
apt-get upgrade -y
apt-get install apache2 -y
apt-get install php -y
service apache2 restart
apt-get install mysql-server php-mysql -y
service apache2 restart
cd /var/www/html/
rm *
tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
chown -R www-data: .
bash_script_4.png
With the BASH script running (with sudo permissions) it runs through and installs the various packages.
bash_script_1bash_script_2
bash_script_3
With the packages installed MySQL and WordPress need configuring, as per:

2 thoughts on “Installing Web Server and WordPress via a BASH script (Rasbperry Pi)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.