Last active
May 2, 2018 14:30
-
-
Save cmbaughman/956e109c9a244ad754f23618435f360b to your computer and use it in GitHub Desktop.
Set up laravel on lamp
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
# These are just the commands to run | |
# This isn't intended to run as a script | |
## Install php mysql and apache2 | |
sudo apt-get update && sudo apt-get -y install software-properties-common python-software-properties | |
sudo apt-add-repository -y ppa:ondrej/php && sudo apt-get update | |
sudo apt-add-repository -y ppa:git-core/ppa && sudo apt-get update | |
export DEBIAN_FRONTEND=noninteractive | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password mysql_password' | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password mysql_password' | |
sudo apt-get -y install mysql-server | |
sudo apt-get -y install php7.1-bz2 php7.1-cli php7.1-curl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-readline php7.1-sqlite3 php7.1-xml php7.1-xsl php7.1-zip php-xdebug apache2 libapache2-mod-php7.1 git curl | |
# Install node | |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
# Install yarn | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update && sudo apt-get install yarn | |
#NOTE: If Ubuntu 17.04 use this sudo apt-get install --no-install-recommends yarn | |
# Get composer | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
sudo php composer-setup.php --install-dir=/usr/bin --filename=composer | |
php -r "unlink('composer-setup.php')" | |
# if the composer file is still in current dir use | |
mv composer /usr/bin | |
# Create your Laravel 5 project | |
composer create-project --prefer-dist laravel/laravel blog | |
# Redis | |
apt install redis-sentinel redis-server redis-tools | |
# These are needed by redis | |
echo never > /sys/kernel/mm/transparent_hugepage/enabled | |
sysctl vm.overcommit_memory=1 | |
# Enable redis and start/restart | |
systemctl enable redis | |
systemctl restart redis | |
systemctl status redis | |
# MySQL | |
mysql -u root -p | |
mysql>CREATE DATABASE dbname | |
mysql>CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; | |
mysql>GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost'; | |
mysql>FLUSH PRIVILEGES | |
#### MySQL Non-interactive version | |
mysql -uusername -ppassword -e "CREATE DATABASE \`laravel\` CHARACTER SET utf8 COLLATE utf8_general_ci;" | |
mysql -uusername -ppassword -e "CREATE USER 'laravel_user'@'%' IDENTIFIED BY 's3cr3t';" | |
mysql -uusername -ppassword -e "USE \`laravel\`; GRANT ALL PRIVILEGES ON `laravel`.* TO 'laravel_user'@'%'; FLUSH PRIVILEGES;" | |
# edit Laravel project .env | |
nano /var/www/projectname/.env | |
# Create login functionality for app | |
php artisan make:auth | |
php artisan queue:table | |
php artisan queue:failed-table | |
php artisan migrate | |
chown -R www-data:www-data bootstrap/cache storage | |
chmod -R g+w bootstrap/cache storage | |
# Apache2 | |
a2enmod rewrite | |
a2enmod ssl | |
add-apt-repository ppa:certbot/certbot && apt update | |
apt install -y python-certbot-apache | |
certbot --apache -d domain.com -d www.doomain.com | |
# Don't forget to edit the *.conf files | |
service apache2 restart | |
service apache2 reload | |
# Run this command to make sure no errors (also shows the active sites) | |
apachectl -S | |
echo ServerName localhost > /etc/apache2/confs-available/fqdn.conf | |
a2enconf fqdn | |
# Everything should be good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment