Are you eager to harness the power of Laravel, one of the most popular PHP frameworks, on your Ubuntu-based server? Installing Laravel on your Ubuntu system is your first step towards building robust web applications with ease and efficiency. In this comprehensive guide, we will walk you through the step-by-step process of setting up Laravel on your Ubuntu environment, ensuring that you have all the tools and knowledge necessary to embark on your web development journey. Let's dive into the world of Laravel and Ubuntu, and unleash the potential of this dynamic combination. 1. Install curl if not already installed 2. install composer if not already installed 3. Now run blow command to install laravel 4. Add laravel to PATH to make it available everywhere 5. Create your Laravel app Now that Laravel is added to path, now all sudoers can create laravel apps using below command if you are not a sudoer, above command will show below error laravel: command not found You can create a link in /usr/local/bin to solve this problem Now non sudoers can create laravel apps like 6.Install mod_rewrite if not already installed You can confirm if its enabled using below command if you created your app inside web server root directory (/var/www/html/) then you can access it like http://localhost/app-name/public 1. Create vhost file The file will look something like this (I’ve removed the comments here to make the file more approachable): First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through. Then ServerName and ServerAlias The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRoot directive to reflect the directory we created: In total, our virtualhost file should look like this: save and close the file. 2. Enable the Virtual Host File When you are finished, you need to restart Apache to make these changes take effect: 3. Set Up Local Hosts File (Optional) hosts file will look something like this For the domain that I used in this guide, assuming that my VPS IP address is 111.111.111.111, if you are creating vhost locally, you can replace 111.111.111.111 with 127.0.0.1 Now that you have your virtual hosts configured, you can test your laravel app easily by going to the domain that you configured in your web browser: http://app-name.comHow to install Laravel on Ubuntu
Last modified
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer
composer global require "laravel/installer=~1.1"
export PATH="~/.composer/vendor/bin:$PATH"
laravel new app-name
sudo ln -s /root/.composer/vendor/bin/laravel /usr/local/bin/laravel
sudo laravel new app-name
sudo a2enmod rewrite
service apache2 restart
sudo apache2ctl -M
Creating VHOST for Laravel application
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/app-name.com.conf
sudo nano /etc/apache2/sites-available/app-name.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
ServerAdmin admin@app-name.com
ServerName app-name.com
ServerAlias www.app-name.com
DocumentRoot /var/www/app-name
<VirtualHost *:80>
ServerAdmin admin@app-name.com
ServerName app-name.com
ServerAlias www.app-name.com
DocumentRoot /var/www/html/app-name/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite app-name.com.conf
sudo service apache2 restart
sudo nano /etc/hosts
127.0.0.1 localhost
111.111.111.111 app-name.com
5 min read