Laravel Project Deployment
- Nov 3, 2022
- 2 min read
Updated: Dec 12, 2022
Web Deployment: It is the process of deploying metadata or content from development environment to production environment (hosting platform). The deployment can be done manually or automatically. Deployment has different approaches with regards to metadata and content, metadata include code, templates, stylesheets, files etc., so deployment of metadata requires a validation and consistency check. While the content include text, images, videos etc., they are less complicated; therefore, deployment of content handled differently to pushing to a live environment.
Duck DNS: It is a free dynamic DNS service that provides public subdomain under ducks.org. By getting subdomain and using provided token anyone can update their records. Once everything is set, through https post every 5 minutes duck DNS has been update with latest external IP, so in this way it keeps the client record update.
Certbot: It is an open-source software for installing free TLS/SSL certificates on websites to enable HTTPS. It provides secure connection between site visitor and web server. For deployment, I have used duck dns subdomain with installed Cerbot on website to enable https.
To deploy the Laravel project, I have moved the project folder into document root directory. At first, I used FileZila ftp application but it took only an hour to download the project and it need another 1 or 2 hours to upload the Laravel Project into root directory.

Therefore, I changed my mind and, because the project was already developed in AWS cloud platform, just by using Linux copy command, I copied the Laravel project to root directory.
cp -r contactapp /var/www/html

Then I changed the ownership of html, contactapp, and public directories and changed the permission of storage directory. On Ubuntu, Apache runs as user www-data, so changing the directories ownership to www-data will allow me to edit web resources published by Apache.
Also, I needed to change the document root. To do this, I have been to etc/apache2/sites-available and from there I have edited document root inside 000-default-le-ssl.conf file.
DocumentRoot /var/ww/htmal/contactapp/public

After Deployment - Broken Image
Despite the contactapp project working at a good standard in Laravel built in server, after deployment into hosting platform, images were broken and not clearly visible.
To resolve this issue, I deleted storage sub directory from public folder, then in routes/web.php I created new route.
Route::get('/link', function(){
Artisan::call('storage:link');
});
Then browse the following link: https:// ss-systems.duckdns.org/link
This way the broken image issue was resolved.
File Access from local storage
The other issue with images was that they were accessible with direct URL because the storage directory is inside the public folder. Based on my understand from research, the only secure way is to change the image directory path and move it outside public folder. However, through .htaccess file I have restricted access to image direct URL, although it is not very secure.





Comments