-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
296 additions
and
184 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,181 @@ | ||
#!/usr/bin/env bash | ||
|
||
# adjust to whatever you like as a MYSQL root password | ||
# adjust to whatever you like as a MYSQL database name | ||
DBPASSWD=root | ||
DBNAME=development | ||
|
||
echo "--- Good morning, master. Let's get to work. Installing now. ---" | ||
|
||
echo "--- Updating packages list ---" | ||
sudo apt-get update | ||
|
||
echo "--- Installing base packages ---" | ||
sudo apt-get install -y vim curl python-software-properties | ||
|
||
echo "--- We want the bleeding edge of PHP, right master? ---" | ||
sudo add-apt-repository ppa:ondrej/php5-5.6 | ||
|
||
echo "--- Updating packages list ---" | ||
sudo apt-get update | ||
|
||
echo "--- MySQL time ---" | ||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASSWD" | ||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASSWD" | ||
|
||
echo "\n--- Installing the phpmyadmin for easier MYSQL database access. It will save you time master. ---\n" | ||
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" | ||
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $DBPASSWD" | ||
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $DBPASSWD" | ||
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $DBPASSWD" | ||
sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none" | ||
sudo apt-get -y install mysql-server-5.5 phpmyadmin | ||
|
||
echo "--- Installing PHP-specific packages ---" | ||
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt mysql-server-5.5 php5-mysql git-core | ||
|
||
echo "--- Installing and configuring Xdebug ---" | ||
sudo apt-get install -y php5-xdebug | ||
|
||
cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini | ||
xdebug.scream=1 | ||
xdebug.cli_color=1 | ||
xdebug.show_local_vars=1 | ||
EOF | ||
|
||
echo "--- Enabling mod-rewrite ---" | ||
sudo a2enmod rewrite | ||
|
||
echo "--- Setting document root ---" | ||
sudo rm -rf /var/www | ||
sudo ln -fs /vagrant/public /var/www | ||
|
||
sed -i "s/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\//" /etc/apache2/sites-available/000-default.conf | ||
|
||
echo "--- What developer codes without errors turned on? Not you, master. ---" | ||
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini | ||
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini | ||
|
||
echo "--- Allowing .htaccess overrides. You will need it master. ---" | ||
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf | ||
|
||
echo "\n--- Configuring Apache webserver to use phpmyadmin ---\n" | ||
echo "Listen 81" >> /etc/apache2/ports.conf | ||
|
||
cat > /etc/apache2/conf-available/phpmyadmin.conf << "EOF" | ||
<VirtualHost *:81> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /usr/share/phpmyadmin | ||
DirectoryIndex index.php | ||
ErrorLog ${APACHE_LOG_DIR}/phpmyadmin-error.log | ||
CustomLog ${APACHE_LOG_DIR}/phpmyadmin-access.log combined | ||
</VirtualHost> | ||
EOF | ||
sudo a2enconf phpmyadmin | ||
|
||
echo "--- Restarting Apache ---" | ||
sudo service apache2 restart | ||
|
||
echo "--- Composer is the future. But you knew that, did you master? Nice job. ---" | ||
curl -sS https://getcomposer.org/installer | php | ||
sudo mv composer.phar /usr/local/bin/composer | ||
|
||
echo "--- Setup database $DBNAME ---" | ||
echo "CREATE DATABASE $DBNAME;" | mysql -u root -p$DBPASSWD | ||
|
||
echo "--- We need laravel installed for out laravel project. Don't we? ---" | ||
composer create-project laravel/laravel /vagrant/laravel --prefer-dist | ||
cd /vagrant/laravel | ||
mv * .[^.]* .. | ||
cd .. | ||
rm -r laravel | ||
sudo chmod -R 777 /vagrant/storage/ | ||
|
||
echo "--- Start setting up environment specific configuration values for our laravel application. ---" | ||
echo "--- Frist, set laravel database credentials. ---" | ||
|
||
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=$DBNAME/" /vagrant/.env | ||
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=root/" /vagrant/.env | ||
sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=$DBPASSWD/" /vagrant/.env | ||
|
||
echo "--- All set to go! Would you like to play a game? ---" | ||
#!/usr/bin/env bash | ||
|
||
# MYSQL | ||
# user: root | ||
# pass: as defined below | ||
# adjust to whatever you like as a MYSQL database name | ||
DBNAME=development | ||
DBPASS=root | ||
|
||
echo "--- Good morning, master. Let's get to work. Installing now. ---" | ||
|
||
echo "--- Updating packages list and upgrading system ---" | ||
sudo apt-get update | ||
sudo apt-get -y dist-upgrade | ||
|
||
echo "--- Start installing ---" | ||
sudo apt-get install -y unzip zip build-essential | ||
|
||
# Apache | ||
echo "--- Installing and configuring apache webserver with bleeing edge PHP FPM ---" | ||
sudo apt-get install -y apache2 | ||
|
||
# Set server name to calm output | ||
sudo echo "ServerName localhost" > /etc/apache2/conf-available/httpd.conf | ||
sudo a2enconf httpd | ||
|
||
# PHP7 | ||
sudo apt-get install python-software-properties software-properties-common | ||
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php | ||
sudo apt-get update | ||
sudo apt-get install libapache2-mod-fastcgi php7.1 php7.1-fpm php7.1-mysql php7.1-curl php7.1-gd php7.1-intl php-pear php7.1-imap php7.1-mcrypt php7.1-ps php7.1-pspell php7.1-recode php7.1-snmp php7.1-sqlite php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-mbstring -y | ||
|
||
sudo a2enmod actions fastcgi alias | ||
|
||
sudo service apache2 restart | ||
sudo service php7.1-fpm restart | ||
|
||
# PHP tweaks | ||
echo "--- Let us configure good PHP defaults, my master. ---" | ||
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.1/fpm/php.ini | ||
sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/fpm/php.ini | ||
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 20M/g" /etc/php/7.1/fpm/php.ini | ||
sed -i "s/post_max_size = 8M/post_max_size = 80M/g" /etc/php/7.1/fpm/php.ini | ||
|
||
# Silent MySQL Install | ||
# http://stackoverflow.com/questions/7739645/install-mysql-on-ubuntu-without-password-prompt | ||
echo "--- Master, it's MySQL time ---" | ||
sudo apt-get update | ||
sudo debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password password $DBPASS" | ||
sudo debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password_again password $DBPASS" | ||
sudo -E apt-get install -q -y mysql-server-5.6 | ||
|
||
# Install Adminer | ||
echo "--- Setup adminer for mysql administration. I hope you like it, my master. ---" | ||
wget http://www.adminer.org/latest.php | ||
mkdir /var/www/adminer | ||
mv latest.php /var/www/adminer/index.php | ||
chown -R www-data: /var/www/adminer | ||
chmod 755 /var/www/adminer/index.php | ||
|
||
# Setup the project database | ||
echo "--- Setup database '$DBNAME' ---" | ||
echo "CREATE DATABASE $DBNAME;" | mysql -u root -p$DBPASS | ||
|
||
# virtual host setup | ||
echo "--- Setting document root for project ---" | ||
sudo rm -rf /var/www/html | ||
sudo ln -fs /vagrant/public /var/www/htdocs | ||
|
||
# setup hosts file | ||
VHOST=$(cat <<EOF | ||
<IfModule mod_fastcgi.c> | ||
AddHandler php7-fcgi .php | ||
Action php7-fcgi /php7-fcgi | ||
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi | ||
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.1-fpm.sock -pass-header Authorization | ||
</IfModule> | ||
<VirtualHost *:80> | ||
DocumentRoot "/var/www/htdocs" | ||
<Directory "/var/www/htdocs"> | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
<Directory /usr/lib/cgi-bin> | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> | ||
Listen 81 | ||
<VirtualHost *:81> | ||
DocumentRoot "/var/www/adminer" | ||
<Directory "/var/www/adminer"> | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
<Directory /usr/lib/cgi-bin> | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> | ||
EOF | ||
) | ||
echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf | ||
|
||
sudo a2enmod rewrite | ||
sudo service apache2 restart | ||
|
||
# Install git | ||
sudo apt-get install -y git | ||
|
||
# Clean up old packages | ||
sudo apt-get -y autoremove | ||
|
||
# Install Composer | ||
echo "--- Composer is the future. But you knew that, did you master? Nice job. ---" | ||
curl -sS https://getcomposer.org/installer | php | ||
sudo mv composer.phar /usr/local/bin/composer | ||
sudo chmod 755 /usr/local/bin/composer | ||
|
||
echo "--- Load a fresh new laravel installation ---" | ||
cd /vagrant/ | ||
composer create-project --prefer-dist laravel/laravel laravel | ||
cd /vagrant/laravel | ||
mv * .[^.]* .. | ||
cd .. | ||
rm -r laravel | ||
|
||
sudo chmod -R 777 /vagrant/storage/ | ||
|
||
echo "--- Make laravel work with current MYSQL version. Have a look at AppServiceProvider for more information on this. ---" | ||
cat > /vagrant/app/Providers/AppServiceProvider.php <<- "EOF" | ||
<?php | ||
namespace App\Providers; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Support\Facades\Schema; | ||
class AppServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// @see https://laravel-news.com/laravel-5-4-key-too-long-error | ||
// required for our server and mysql setup | ||
Schema::defaultStringLength(191); | ||
} | ||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} | ||
EOF | ||
|
||
echo "--- Start setting up environment specific configuration values for our laravel application. ---" | ||
echo "--- First, set laravel database credentials. ---" | ||
|
||
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=$DBNAME/" /vagrant/.env | ||
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=root/" /vagrant/.env | ||
sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=$DBPASS/" /vagrant/.env | ||
|
||
echo "--- Let's setup the laravel auth service for this project, my master. ---" | ||
|
||
cd /vagrant/ | ||
php artisan make:auth | ||
php artisan migrate | ||
|
||
echo "--- All set to go! Would you like to play a game? ---" |
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
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
Oops, something went wrong.