Fellas, Greetings. I have a dev laravel project that i want to use on public so am wondering what is the best hosting platform ? If someone suggesting Amazon i appreciate to share your experience and how should i deploy it in a live environment.
-
Refer: https://dzone.com/articles/how-to-deploy-laravel-application-on-aws-ec2-the-r – Rahul Shukla Jul 26 '19 at 10:26
-
Looks very professional , i will try and i will let you know with the update. Thanks Rahul. – Ahmed M Jul 26 '19 at 10:38
-
I can suggest my guide for how to setup a Laravel application on the server. https://www.amezmo.com/laravel-hosting-guides/deploy-a-laravel-application-to-amezmo – Ryan Jul 09 '20 at 05:35
5 Answers
Its very Simple to setup the AWS server Apache, Laravel, Mysql
Step 1
Create Instance AWS then enable Security Group ssl to http
SSH connection with your terminal
download pemfile
Connection Command for SSH connection
'ssh -i "C:\Users\vicky\Desktop\klm.pem" ec2-user@12.1.198.1576'
Step 2
HOME DIRECTORY
sudo yum update -y
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
cat /etc/system-release
sudo yum install -y httpd mariadb-server
sudo yum info package_name
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl is-enabled httpd
Add a security rule to allow inbound HTTP (port 80) connections to your instance if you have not already done so. By default, a launch-wizard-N security group was set up for your instance during initialization. This group contains a single rule to allow SSH connections. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Choose Instances and select your instance.
On the Security tab, view the inbound rules. You should see the following rule:
Port range Protocol Source
22 tcp 0.0.0.0/0
Apache is setup check IP on browser
Then
sudo usermod -a -G apache ec2-user
exit
groups
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
Tets Lamp servet install p[hp 7.2 ]
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
sudo yum list installed httpd mariadb-server php-mysqlnd
rm /var/www/html/phpinfo.php
sudo systemctl start mariadb
sudo mysql_secure_installation
When prompted, type a password for the root account.
Type the current root password. By default, the root account does not have a password set. Press Enter.
Type Y to set a password, and type a secure password twice. For more information about creating a secure password, see https://identitysafe.norton.com/password-generator/. Make sure to store this password in a safe place.
Setting a root password for MariaDB is only the most basic measure for securing your database. When you build or install a database-driven application, you typically create a database service user for that application and avoid using the root account for anything but database administration.
Type Y to remove the anonymous user accounts.
Type Y to disable the remote root login.
Type Y to remove the test database.
Type Y to reload the privilege tables and save your changes.
(Optional) If you do not plan to use the MariaDB server right away, stop it. You can restart it when you need it again.
sudo systemctl stop mariadb
sudo systemctl enable mariadb
sudo yum install php-mbstring -y
sudo systemctl restart httpd
sudo systemctl restart php-fpm
cd /var/www/html
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
rm phpMyAdmin-latest-all-languages.tar.gz
Check phpMyAdmin on browser
sudo systemctl is-enabled httpd
After server setup UPdate PHP 7.2 to 7.3
sudo amazon-linux-extras list
sudo amazon-linux-extras disable php7.2
sudo amazon-linux-extras disable lamp-mariadb10.2-php7.2
sudo amazon-linux-extras enable php7.3
sudo yum install php-cli php-pdo php-fpm php-json php-mysqlnd
sudo amazon-linux-extras disable php7.3
Laravel actually provides some of their own services to make managing a server easier.
Laravel Forge handles deployments, databases, security updates and more for you for a small monthly fee. Note that forge merely manages your server that for example lives on AWS, Linode or Digital Ocean.
Another alternative is the newly announced Laravel Vapor platform, which is using the "server-less" paradigm, for elastic scaling of your application. I however think it would be overkill for you, since it sounds like you just want to share a simple project with a couple of other users.
Like Jonas suggested, Vapor is an option. I think its better for you since its based on serverless technology. If you want to know more about serverless architecture, read this: https://aws.amazon.com/lambda/serverless-architectures-learn-more/
This is a good article about how to deploy your app to vapor, pretty straight forward. https://www.2hatslogic.com/blog/deploy-web-app-laravel-vapor/

- 814
- 1
- 11
- 23
AWS is a fine choice for hosting, but it comes with a learning curve. If you don't mind spending a few hours, or days learning AWS, then I would suggest it because learning DevOps is a valuable skill that will follow you for your entire career.
You can also use a combination of Forge + Envoyer. The latter being strictly for zero-downtime deployments, and Forge being the server provisioning tool that can work with any VPS provider.
(Founder here). If time is an issue, then I'll suggest using Amezmo because it will allow you to get up and running faster without spending time reading documentation. There's also a full guide for Laravel hosting: https://www.amezmo.com/laravel-hosting-guides/deploy-a-laravel-application-to-amezmo

- 14,392
- 8
- 62
- 102
First of all add your project into a bitbucket repository. Clone your project into the directory of /var/www/html and give that folder the permission of 777. Copy your .env file using command sudo cp .env.example .env Change your database settings in the .env file. Run composer install in the root directory of project. Run php artisan migrate:fresh --seed Run php artisan key:generate and you're ready to run your laravel application on your ec2 instance.

- 83
- 5