Almost Automatic WebServer Installer

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
Yoshi2889

Almost Automatic WebServer Installer

Post by Yoshi2889 »

I wanted to install a complete webserver on my laptop, but I'm too lazy to install the stuff myself. So I wrote this little script which installs Apache 2, PHP 5 and MySQL along with phpmyadmin and the links for you.

System Requirements
- A Linux operating system with APT-GET command (aka APT packager)
- Working internet connection
- A terminal

How to use
Place the file anywhere you like, mark it as executable (Right click > Properties > Rights > Allow execution) and run it from a terminal WITH SUDO (you can drag and drop the file in the terminal after you typed "sudo " (no the space is not a typo)). So if you have it in your Downloads folder:

Code: Select all

sudo ~/Downloads/installWebServer.sh
The installers for MySQL and phpMyAdmin will ask you a few things.

You can also run the installer to update the components installed.

Tested on
- Linux Mint 13 Cinnamon 64-bit as main OS
- Ubuntu 12.04 64-bit in VirtualBox

Download
installWebServer.sh.tar.gz
Try it out, and please report bugs to me :)
sagirfahmid3

Re: Almost Automatic WebServer Installer

Post by sagirfahmid3 »

It is absolutely NOT necessary to download this script. I'm sorry, I'm not trying to be rude or anything, but a script to install only THREE things is a LOT of time wasted (especially with all those prompts).

Simple 3 liner code to paste in terminal to do whatever the script does (source: https://help.ubuntu.com/community/ApacheMySQLPHP ):

Code: Select all

sudo apt-get install apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql
Contents of script below (it is ALWAYS a good idea to post the contents along so users may see what is within):

Code: Select all

#!/bin/bash

clear

# Prompt the user for confirmation, don't do anything when the user doesn't want to!
echo 'Welcome! This script will install Apache 2, PHP 5, MySQL and phpMyAdmin for you. Do you wish to continue?'
echo '[Y/n] '

read -n 1 yn

if [ $yn == 'n' ]
	then
		echo ''
		echo 'Too bad. Lets hope you come back at another time.'
		exit;
fi

echo 'Okay, I will now go on with installing Apache. Please do not open localhost in the meantime. If this fails, please run this script with SUDO.'
# Unattended install of the apache2 package.
sudo apt-get -q -y install apache2

echo 'Done! Lets install PHP now.'

# Install PHP5
sudo apt-get -q -y install php5

echo 'Also done! Wonderful. Lets install MySQL now.'

# Install the MySQL server.
sudo apt-get -q -y install mysql-server

echo 'Awesome, just a few more things to install and we are done. Please be patient as things do not work when I am busy.'

# Install the link between Apache and PHP.
sudo apt-get -q -y install libapache2-mod-php5
# And between PHP and MySQL
sudo apt-get -q -y install php5-mysql
# Now install phpmyadmin
sudo apt-get -q -y install phpmyadmin

echo ''
echo 'CHMODding /var/www to 0755...'
sudo chmod -R 0755 /var/www

echo ''
echo 'Done! You can now access your webserver at http://localhost/. The files are stored in /var/www. Please run "sudo chown -R (your username) /var/www" to write files to the directory. Have fun with your webserver!'
Edit: PS, I also run a webserver. The command is "sudo apt-get install apache2 mysql-server phpmyadmin" and all the other packages are dependencies that are automatically pulled in and installed.
Yoshi2889

Re: Almost Automatic WebServer Installer

Post by Yoshi2889 »

Heh, I know. I was just bored and wanted to learn a bit of bash.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Almost Automatic WebServer Installer

Post by xenopeek »

Moved here by moderator
Image
Post Reply

Return to “Tutorials”