问题
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 connected my server with using FileZilla. and I tested I can put a simple abc.html file and can be accessed with ___.com/abc.html
How to deploy my laravel project to my server? Can I just upload the whole laravel project to server then can access without any command? or must need to remote with SSH and install something?
Thanks!
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/38510520/how-laravel-deploy-with-ftp