Making the Application Live & Final Conclusion

 Making the website live seems like the biggest challenge but in fact it wasn't difficult at all. It was only few steps and I kept the copy of App that works on the localhost as well just in case. 


First step was to copy the blog directory which contains whole app and paste it to the root directory location:
  cp -r /home/ubuntu/blog /var/www/html

Then I simply had to add the permissions to new directory, which is now:
/var/www/html/blog
The permissions line are:
sudo chown www-data:www-data /var/www/html/ -R
sudo chown www-data:www-data /var/www/html/blog -R
sudo chown www-data:www-data /var/www/html/blog/public -R
sudo chmod 775 /var/www/html/blog/storage -R

The following chown commands will change the ownership of all files and subdirectories under the /var/www/html... directories to a new owner and group named www-data.
www-data
is an user (and group) that the service httpd (apache) acts with on my system.
chmod 775 command is essential as it assigns read, write, and execute permission to the user or a group.

Then in etc/apache2/sites-available we edit a 000-default-le-ssl.conf file by changing the:
DocumentRoot /var/www/html

to:

 

After that it is important to remember to restart apache! 

And that's all! the website is now accessible live (as long as the instance is running) at:
https://anita-final-year.duckdns.org/

 

Appeared problem and its solution:
When I was testing if everything works as it supposed to after making my website live, I noticed that whenever I create a new post the thumbnail for it doesn't exist. It gets stored in database but it isn't passed to the public folder to be accessable by users. The link connecting the storage with public storage was created but for some reason it didn't work. To fix that issue I had to delete the public/storage directory, create a special route for that link in web.php and then create a link one more time with
php artisan storage:link command.

The whole process looks like this:


It is impossible to relink it without deleting the public/storage folder first. After that the link started working and all post thumbnails are visible again.
  

It is also important to change this line of code in our .env file from true to false, as this will prevent showing all errors (and at the same time view into some files) to the users, it will instead show them the message about occuring error (but without any details), for example when the route they typed in doesn't exist.

APP_DEBUG=false

When it is set as true:



When it is set as false:

Conclusion

The most important thing I learned from that project was that testing is really important especially after making the website live. Functionalities that worked perfectly on local server may not work that well or even not work at all on public one. It was also helpful to send the link to my live website to others and ask them to complete given tasks. Here is the list of tasks that I created for testing purposes:


I also learned that templating is a very important thing and as I mentioned in "Blade Templates" post I will use them for my future Laravel based projects. Although I have to remember that once the template is in the browser it no longer belongs to the developer so all the authorization and authentication used in it should be included in the middleware and routes for the protection and security.

All the mistakes I made, problems with code or application functionality that occured during the development stage and solutions I found for them can be found in "Appeared problem and its solution" sections in all my previous posts as I tried to describe the develoment process step by step.

It is also important not to be scared to look for problem solutions online, these are some helpful websites that helped me through my development stage:
https://laravel.io/forum/images-showing-in-built-in-server-but-not-after-deployment
https://laravel.com/docs/9.x
https://stackoverflow.com/
https://www.php.net/manual/en/index.php
https://laracasts.com

Thank you for following my blog! 👍

Komentarze