Last active
March 7, 2018 06:11
-
-
Save Compro-Prasad/21978ba75c3cc78659b186a0bc0a059f to your computer and use it in GitHub Desktop.
Install php, mysql and apache and connect to an existing project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if which apt > /dev/null; then | |
echo "No support for your device" | |
exit | |
fi | |
if which firefox > /dev/null; then | |
echo "Firefox found" | |
BROWSER=firefox | |
elif which chromium > /dev/null; then | |
echo "Chromium found" | |
BROWSER=chromium | |
elif which google-chrome > /dev/null; then | |
echo "Google Chrome found" | |
BROWSER=google-chrome | |
fi | |
echo "Updating package list" | |
sudo apt update | |
echo "Installing LAMP" | |
sudo apt install php php-mysql mysql-server mysql-client apache2 libapache2-mod-php | |
cd /var/www/html | |
echo -n "Enter name of your project directory: " | |
read dir | |
echo -n "Enter full path to your project directory: " | |
read path | |
echo "Linking your project to the server" | |
sudo ln -s "$path/$dir" "$dir" | |
php 2>/dev/null << EOF | |
<?php | |
if (function_exists("mysqli_connect")) | |
echo "Mysql connected with PHP" . PHP_EOL; | |
else | |
echo "Mysql can't connect with PHP" . PHP_EOL; | |
?> | |
EOF | |
echo "You can now access your project at http://localhost/$dir" | |
echo -n "Do you want to open this link in your browser? [y/n] " | |
read x | |
if [ $x = 'y' ]; then | |
$BROWSER http://localhost/$dir | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment