My probelms when setting up statamic

16.03.24

This is an blog post about the issues I faced when trying to make this webstie using the statamic CMS (Content managment system). I was using windows and WSL to set up the website (which probaly wasnt the best idea and would recommend just using linux is possible) and used ploi to manage the site. The reason I chose ploi to manage my site is beacuse it is free for one site and server and that it is bulit to be used with laravel and has integration with statamic however I recommend to do your research beacuse I am new to website hosting and deploying and if you have any tips on how to host this blog please email here.

Class "finfo" not found

This happened when I was trying to test my website to see if every think was set up correctly using the php artisan serve or when I was trying to use the composer to install the dependencies needed for the website. The fix to this was to use the php --ini command to see what php configuration was being used and then uncomment the extension=fileinfo and then it worked for me (to uncomment just remove the ; before the extension). A PHP extension is libary or plugin that allows addtional usage like a normal libary and the fileinfo extension trys to guess what the file type is by using magic bytes in the file.

Probelms displaying Images

Also when adding images to the blog the GD not installed error would show up this is again beacuse the extention for GD needs to be uncommented in the php.ini the location of this file can be found by using the php --ini command and then uncomment the extension=gd. To fix it on linux need to install the package associated with the GD extention this can be done using the following command sudo apt-get install php-gd and then images should be displayed for this to work may have to reload the php service sudo service php8.3-fpm reload (replace the 8.3 with your version).

WSL

On WSL my version of PHP wasnt being recognised as a valid version when i was trying to run statamic so I just uncommented the lines of code that was responsible for the check and ran it again and it worked.

Curl Error

This error happened when I was trying to use a started kit and got an error saying that cURL error 60: SSL certificate problem: unable to get local issuer certificate. I belive that this is beacuse windows uses invoke web expressions instead of actual curl however this is different in versions above 1803. There is a tutorial on how to install curl for windows that can be found here but to fix it for me I just used the wsl curl and it worked and the strated kit was successfully installed.

Ploi

I recomend following the deploying method that was show on the statamic website which can be found here and just using the server provider ( cloud provider) of your choice. Assuming you have an ploi account you can then start a server using the api key from your cloud provider as the credential for your server and when the server is deployed will recive an email ( on the same email the account was created with) for the ssh credentials to login the server and the username which is ploi. However I recommend adding ssh keys to the server for easier login and safer. All you have to do is ssh-keygen -t rsa -b 4096 to generate the keys assuming you are on linux and then copy the public key (the key with the .pub extenstion) to the ssh key box and then saving the key and then just using ssh ploi@ip_address to login to the server. For information on setting up the ssh on windows go here and for macos go here.

Once the server is up and running and can ssh in can follow the instructions provided by statamic but make sure to create a repo when installing statamic for the site as this will make it easier when deploying the website and changing the website from your own manchine and deploying it to the server. Can also set up github actions so that when a push happens on the repo the website will automatically will be updated but it is easier to just use ploi manually every time you change the website on your local manchine and push it to the repo and then just run the deploy script to update the webstie from the repo.

Making sure changes are made

Always get in the habbit on clearing the cache and routing information when making changes to the website the following is the list of all commands to run to make sure changes will be made.

php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan statamic:stache:warm
php artisan queue:restart
php artisan statamic:search:update --all
php artisan statamic:static:clear

Artisan is a command line interface that is included with Laravel that provides a number of useful commands that can assist you in buidling your application to view all the commands that artisan can use do the following php artisan list.

npm run production

Some of the bulid scripts on the statamic website will try you to use the npm run production to deploy the webstie but this is an old way to bulid the website and should use npm run build instead. Before executing this command make sure that sudo npm install which will install the dependencies needed for the website or can use sudo npm ci for a clean install which will install the exact versions of the dependencies needed as defined in the package-lock.json.

Website with no control pannel

If you dont want the control pannel to be able to be accessed on the website when in production can use composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev which will not install the dependencies needed to access the control pannel and deploy it faster.

Overall

This were just my issuses with buliding the website this is my frist time using statamic to bulid a website so there may be some mistakes on my half. If you notice any think wrong in the content of the blog please tell me via email. Your feedback is greatly appreciated, and I will promptly correct any errors.


Related Articles can be found here:


  • Website Dev
  • PHP
  • Statamic