# Install git
sudo apt-get install git vim
# Add ondrej/php ppa
sudo apt-add-repository -y ppa:ondrej/php
# update package
sudo apt-get update -y
# Install php 7 and or 5.6, mysql-server, apache2, and required packages
sudo apt-get -y install php7.0 php5.6-mysql php5.6-cli php5.6-curl \
php5.6-json php5.6-sqlite3 php5.6-mcrypt php5.6-curl php-xdebug \
php5.6-mbstring libapache2-mod-php5.6 libapache2-mod-php7.0 mysql-server-5.7 apache2
# Once we have PHP 5.6 (or 5.5) and 7.0 installed,
# we can easily switch between them from the shell using these commands.
# To enable PHP 5.6 (and disable PHP 7.0) use this command:
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php
# Similarly, to switch from PHP 5.6 to PHP 7.0, use this command:
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php
# Even better, we can set an alias in our bash file
# .zshrc for (zsh terminal) and .bashrc for (bash terminal, this is default in ubuntu)
vi ~/.bashrc
alias phpv5='sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php'
alias phpv7='sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php'We can restart apache simply by running sudo service apache2 restart
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restartcurl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composercd /var/www
chown -R www-data.www-data /var/www/
git clone https://github.com/laravel/laravel.git
chmod -R 755 /var/www/laravel
cd laravel
[sudo] composer installphp artisan key:generateNOTE: if you get any errors, you can try
composer update --no-scriptsto fix it.
I love vim editor, you can use your preferred editor
sudo vi /etc/apache2/sites-available/laravel.example.com.conf
<VirtualHost *:80>
ServerName laravel.example.com
DocumentRoot /var/www/laravel/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/laravel>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# enable lavarel.example.com VirtualHost
a2ensite laravel.example.com
sudo serivce apache2 reloadsudo echo "127.0.0.1 laravel.example.com" >> /etc/hosts
All the setups are now done, you can visit http://laravel.example.com/ in your browser and it should work.