(How) Laravel Deploy with FTP

前端 未结 3 1189
半阙折子戏
半阙折子戏 2021-01-23 01:26

I built a laravel project and I normally use localhost with the command \"php artisan serve\" to test my project

But now, I want to host on server. I successfully connec

相关标签:
3条回答
  • 2021-01-23 02:21

    Deploying to Shared Hosting:

    Zip your project and upload it to public_html and Extract it

    Create Database in mysql databases ( in cPanel )

    Import .sql file from local phpmyadmin to online hosting

    Now go to public_html and edit .env file, change the following

    DB_DATABASE=yourdatabasename
    DB_USERNAME=database username
    DB_PASSWORD=database password
    

    and now just open yourwebsite.com and your app will be there !

    Deploying On Cloud Hosting

    First of all go to your site or host/phpmyadmin and create new database and upload your sql database file ( which you can import from local phpmyadmin )

    Create Drop and upload all files

    Click on create new droplet and select LAMP from applications tab , now upload all files to your droplets folder (/var/www/html) through filezilla

    Note : Make sure you changed database username , password and name in .env before uploading

    Connect to droplet through SSH (Putty) Now connect to droplet through putty and run below commands

    chgrp -R www-data /var/www/html

    chmod -R 775 /var/www/html/.env

    chmod -R 775 /var/www/html/storage

    chmod -R 775 /var/www/html/bootstrap

    chmod -R 775 /var/www/html/public/uploads

    Enable Modules

    Run below command to enable mod_rewrite module

    sudo a2enmod rewrite
    

    Now open 000-default.conf

    sudo nano /etc/apache2/sites-available/000-default.conf
    

    Add below lines below

     AllowOverride all 
    

    Now restart apache2 server

    sudo service apache2 restart 
    

    That's it now go to your site.com and app will be dancing there.

    0 讨论(0)
  • 2021-01-23 02:23

    Simply drag and drop the root folder to your server's root. Not to the public_html directory. The only thing that should be in the public_html directory is Laravel's "public" directory (thus you have to rename it, depending on your server's settings).

    Do not put your configuration files inside the public_html folder or anyone will be able to access them and steal your data.

    0 讨论(0)
  • 2021-01-23 02:24

    Did you make sure that you pointed the web server to the public/ folder? There is an index.php file in that folder that bootstraps the entire site.

    0 讨论(0)
提交回复
热议问题