مرا اسکن کن!

نصب Laravel 5.6 بر روی سرور Ubuntu 18.04 LTS

نصب Laravel 5.6 بر روی سرور Ubuntu 18.04 LTS



لاراول یکی از بهترین فریم ورک های برنامه نویسی حال حاظر دنیا هست که برای زبان php نوشته شده.

این آموزش برای نصب laravel 5.6 بر روی سرور ubuntu 18نوشته شده ولی برای دستورات برای نصب بر روی اوبونتو ۱۷ هم میشه استفاده یشه ولی با توجه به اینکه آخرین نسخه اوبونتو یعنی اوبونتو ۱۸ LTS(long time support) هست پیشنهاد می کنم حتما از این نسخه استفاده کنید.

 

قبل شروع نصب ابتدا با اجرای دستور زیر خوبه که سیستم رو برای افزونه های امنیتی و آپدیت ها بروزرسانی کنبم.

sudo apt-get update 
sudo apt-get upgrade

قبل از نصب لاراول ما باید افزونه های مورد نیازمون رو نصب کنیم.

نصب Apache و PHP7.2

Next step is to install PHP along with several extra packages that would prove useful if you are going to work with Laravel. 

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-php7.2 php7.2 php7.2-xml php7.2-gd php7.2-opcache php7.2-mbstring

Even though Ubuntu's own repository has PHP, it's better to add a 3rd party repository here because it gets more frequently updated. You can skip that step and stick to Ubuntu's version if that's what you prefer.

Installing Laravel

Before we finally delve into it, we also need Git version control to be installed. If you have it installed, you can skip the following step. If you don't have, then you can follow our guide to set it up first.

To install Laravel, we need to install Composer first. It is a tool for dependency management in PHP that allows you to package all the required libraries associated with a package as one. To install Laravel and all its dependencies, Composer is required. It will download and install everything that is required to run Laravel framework. To install Composer, issue the following commands.

cd /tmp
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

The curl command downloads composer.phar package to your /tmp directory. But we would want composer to run globally hence we need to move it to /usr/local/bin/ directory under the name 'composer'. Now we can run composer from anywhere.

To install Laravel, move to the public html directory on your system. Since we are on Ubuntu and using Apache, we will install it in the /var/www/html directory.

cd /var/www/html
sudo composer create-project laravel/laravel your-project --prefer-dist

The above command will create a "your-project" directory with Laravel installation in it. Composer uses git to download and install all the packages and modules that Laravel requires for functioning.

Configuring Apache

Now that we have installed Laravel, we move on to the step of configuring Apache web server.

Next step is to give proper permissions to the project directory. For this, we need to enable access to it from the www-data group and to give it writing permissions to the storage directory.

sudo chgrp -R www-data /var/www/html/your-project
sudo chmod -R 775 /var/www/html/your-project/storage

Now go to the /etc/apache2/sites-available directory and use the following command to create a configuration file for our Laravel install.

cd /etc/apache2/sites-available
sudo nano laravel.conf

Now add the following content to the file and close it after saving. Replace yourdomain.tld with the domain name of your website inside the file.


    ServerName yourdomain.tld

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/your-project/public

    
        AllowOverride All
    

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Now we have to enable this newly created .conf file and disable the default .conf file that is installed with the default Apache install. Also, we need to enable mod_rewrite so that permalinks can function properly.

sudo a2dissite 000-default.conf
sudo a2ensite laravel.conf
sudo a2enmod rewrite
sudo service apache2 restart

Your Laravel installation is now complete. Visit the IP address or domain name of your server with a web browser (in my case http://192.168.1.100). You will see the Laravel default page.

Laravel installed on Ubuntu 18.04 LTS

Laravel Framework successfully installed on Ubuntu 18.04 LTS.

Virtual machine download of this tutorial

This tutorial is available as ready to use virtual machine image in ovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:

SSH / Shell Login

Username: administrator
Password: howtoforge

To become root user, run: sudo -s
Password: howtoforge

The IP of the VM is 192.168.1.100, it can be changed in the file /etc/netplan/01-netcfg.yaml. Please change all the above passwords to secure the virtual machine. 


نوشته شده توسط :

وحید صمدیان وحید صمدیان



چهارشنبه, 9 خرداد 1397

تعداد بازديد : 605

برچسب ها : شبکه و ارتباطات

3.0 ستاره