Tuesday, March 28, 2023

RUN LINUX COMMAND IN VAGRANT HOMESTEAD @ START UP

I got error on my application when starting up the homestead, to fix this, I need to vagrant ssh and run a linux command. This method works with me

Edit your VagrantFile, replace the command in `inline`
go to the bottom line of the file and copy paste the command


Vagrant.configure("2") do |config|
  config.vm.provision "shell", run: "always", inline: "service nginx restart"
end

Tuesday, March 14, 2023

HOW TO SET GIT BASH AS THE DEFAULT TERMINAL IN YOUR VISUAL STUDIO CODE

 


This simple steps works on me

  • press down CTRL + SHIFT + P and then type in “select default profile“.
  • The drop-down includes every shell that is installed in your system that VS Code was able to detect.
  • Now simply select Git Bash and open up a new terminal window by pressing down CTRL + SHIFT + ~ (tilde) to check if Git Bash opens up as the default terminal.

Friday, March 3, 2023

HOW TO CREATE AN IMAGE IN PORTAINER FOR PHP8 AND APACHE TO RUN A WEB APPLICATION

Go to Image and build a New Image


Give it a name

and put this value in Web Editor portion

FROM php:8.0-apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN apt-get update
RUN apt-get install -y \
    git \
    zip \
    curl \
    sudo \
    unzip \
    libicu-dev \
    libbz2-dev \
    libpng-dev \
    libjpeg-dev \
    libmcrypt-dev \
    libreadline-dev \
    libfreetype6-dev \
    g++

RUN docker-php-ext-install \
    bz2 \
    intl \
    bcmath \
    opcache \
    calendar \
    pdo_mysql \
    mysqli \
    gd

# 2. set up document root for apache
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf

# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers

# 4. start with base php config, then add extensions
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# 5. Composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer self-update


ARG phpver=8
ARG git_repo="https://gitlab+deploy-token-1823228:tRSTqEaK7dviW47zXd_zw@gitlab.com/repoAccount/repo.git"
ARG webapppath="/var/www/html/your-foldername"
ARG max_execution_time
ARG max_input_time
ARG max_input_vars
ARG memory_limit
ARG post_max_size
ARG upload_max_filesize
ARG session_maxlifetime

#Clone source code
RUN git clone $git_repo $webapppath -b develop

RUN chmod -R 755 $webapppath/writable/ 
Run chown -R www-data:www-data $webapppath/writable/ 

RUN composer update --working-dir=$webapppath

RUN cp $webapppath/env $webapppath/.env

ARG uid=1000
ENV UID=$uid

RUN useradd -G www-data,root -u $UID -d /home/devuser devuser
RUN mkdir -p /home/devuser/.composer && \
    chown -R devuser:devuser /home/devuser

EXPOSE 80

===================================

Create 000-default.conf and change the value of your-foldername and upload it to Select Files button




then Build Image

  • For webapppath = edit this to your exact foldername

  • Note for ARG git_repo , if you are using gitlab. You may need to create a deploy token of your repository in able to download or clone your repository even without inputting any credential. You may check the gitlab documentation on how to create deploy token.

DONE!!
(you may now create your stack for this image for any modification, stack will create your container!)






Wednesday, March 1, 2023

502 BAD GATEWAY ERROR WHILE INSTALLING VAGRANT BOX TO RUN A LARAVEL PROJECT with 7.4 PHP

 To fix this what I did is.


go to your Homestead folder

run: vagrant ssh

type: sudo passwd root

type what password you want for root

then type: su

run the ff. commands

sudo systemctl enable php7.4-fpm
sudo service php7.4-fpm restart

Done!