Fix Laravel Storage Permissions and logs

Fix Laravel Storage Permissions Install Dependencies n Clear Cache

Fix Laravel storage permissions, install dependencies, resolve npm build issues, and clear cache with essential commands for smooth deployment.

Storage Permission Fixing on VPS Server

Make sure the directories for Laravel’s storage and cache exist and are writable

mkdir -p storage bootstrap/cache \
    && mkdir -p storage/framework/cache data storage/framework/sessions storage/framework/views bootstrap/cache \
    && find . -type d -exec chmod 755 {} \; \
    && find . -type f -exec chmod 644 {} \; \
    && chown -R root:root storage bootstrap/cache \
    && chmod -R 777 storage bootstrap/cache \
    && chown -R root:root public

php artisan optimize:clear

composer du

Storage permission fixing on hosting panel

Run below commad if you are using come panels like virtualmin, webmin, cPanel etc. beacuse we no need to set any permission using chown, by default ownership is okey.

mkdir -p storage bootstrap/cache \
    && mkdir -p storage/framework/cache data storage/framework/sessions storage/framework/views bootstrap/cache \
    && find . -type d -exec chmod 755 {} \; \
    && find . -type f -exec chmod 644 {} \; \
    && chmod -R 777 storage bootstrap/cache \

chmod -R 777 /var/www/html/<project>storage ()

php artisan optimize:clear

composer du

Vite: Permission denied

If you execute npm run build script, you may receive the error vite: Permission denied. json file, such as npm run build, which eventually runs vite. This error occurs because maybe you insatlled npm packages using sudo and your user does not have permission now to access the node_modules directory. so, simply remove node_modules and install it again without sudo.

rm -rf node_modules

//OR if above command failed
# sudo chown -R me ./node_modules

npm install
npm run build

Install basic Ubuntu packages

sudo apt-get update && apt-get install -y \
    git \
    curl \
    libjpeg-dev \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip \
    supervisor \
    vim \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libz-dev \
    libzip-dev

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *