Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installation of Laravel on Ubuntu 16 server
#
# Requirements:
# - Ubuntu server
# - Root password for ubuntu server
# ssh into the server from local computer
ssh root@{server_name or server_ip_address}
#Updating ubuntu base packages
sudo apt-get update
#Installing apache2 on server
sudo apt-get install apache2
#Enabling mod rewrite, so laravel can rewrite .htaccess configurations
sudo a2enmod rewrite
#Apache service restart
sudo service apache2 restart
#Installing mysql on ubuntu
sudo apt-get install mysql-server
#securing mysql installation
sudo mysql_secure_installation
#Installing php and all required php extensions for laravel
sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-zip php7.0-xml php7.0-mysql
#Installing composer on ubuntu
sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
#get into directory for laravel installation
cd /var/www/html
#Installing laravel blank project
composer create-project laravel/laravel --prefer-dist project
#Making laravel directories writable
sudo chmod -R 775 /var/www/html/
sudo chmod -R 775 /var/www/project/storage
sudo chmod -R 775 /var/www/project/bootstrap/cache
##########-->edited --> run this command, mentioned in second video
chmod -R o+w project/storage
#Configuring a new virtual host for laravel app
cd /etc/apache2/sites-available/
sudo cp 000-default.conf project.conf
#Open up text editor and edit file
sudo nano project.conf
#
#<VirtualHost *:80>
# ServerName server_ip
# ServerAdmin server_admin_account
# DocumentRoot /var/www/html/project/public
# <Directory "/var/www/html/project">
# AllowOverride All
# </Directory>
#
# ErrorLog ${APACHE_LOG_DIR}/error.log
# CustomLog ${APACHE_LOG_DIR}/access.log combined
#
#</VirtualHost>
#
#enable newly created virtual host
sudo a2ensite project.conf
#disable default conf file
sudo a2dissite 000-default.conf
#Reload apache
sudo service apache2 restart
#logging into mysql
mysql -u root -p'yourpassword'
#create new mysql database
CREATE DATABASE udemy-forum;
#setting up git hooks
cd /var
mkdir repo
cd repo
mkdir site.git && cd site.git
git init --bare
cd hooks
sudo nano post-receive
#insert git hook into the post-receive file
# #!/bin/sh
# git --work-tree=/var/www/html/project --git-dir=/var/repo/site.git checkout -f
#giving permission to post-receive file , so it can move files around
sudo chmod +x post-receive
#local machine git commands - add remote
git remote add production ssh://root@{server_ip}/var/repo/site.git
#push to master
git push production master
#LARAVEL CONFIGURATIONS
cp .env.example .env
#editing .env file
sudo nano .env
#artisan commands to run
php artisan config:cache
php artisan migrate
php artisan db:seed
#DONE !!
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment