Tuesday, April 16, 2024

INSTALL PHP USING COMMAND LINE TOOL FOR WINDOWS

You need to run this in powershell (Admin)

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco upgrade chocolatey 

 

choco install php 

you can specify version

choco install php --version=7.4.1 

 


last step is to update windows environment, to do that you need to run these codes.

  1. Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"

  1. Update-SessionEnvironment
php -v



And your done! :)

Sunday, June 25, 2023

Switch php version command line inside vagrant homestead

 If you want to switch the PHP version in the command line of your Homestead Vagrant box, you can follow these steps:


1. SSH into your Homestead Vagrant box by running the following command from your project's root directory:

   ```

   vagrant ssh

   ```


2. Once you are inside the Vagrant box, you can use the `update-alternatives` command to switch the PHP version. Run the following command to see the available PHP versions:

   ```

   sudo update-alternatives --config php

   ```


3. The command will display a list of available PHP versions installed on your system. Each version will have a corresponding number associated with it. Enter the number of the PHP version you want to switch to and press Enter.


4. After selecting the PHP version, it will be set as the default version for the command line.


5. To verify the PHP version, you can run the following command:

   ```

   php -v

   ```


That's it! You have now switched the PHP version in the command line of your Homestead Vagrant box. The selected PHP version will be used for any subsequent PHP command you run from the command line.

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!


Tuesday, February 21, 2023

HOW TO CREATE A NEW INSTANCE PHPMYADMIN IN DOCKER, DIRECTLY TO YOUR CLOUD SERVER

You can use this whenever you want another instance of phpmyadmin connected to your cloud mysql server

docker run --name phpmyadminContainerName -d -e PMA_HOST=[hostname] -e PMA_USER=[user] -e PMA_PASSWORD=[password] -p 8088:80 phpmyadmin/phpmyadmin

Replace [YOUR_HOSTNAME], [YOUR_USERNAME], and [YOUR_PASSWORD] with your own values. This command will start the phpMyAdmin container in the background and expose it on port 8088 of your local machine. You can access phpMyAdmin by opening a web browser and navigating to http://localhost:8088.