VisitFolio
VisitFolio

Here you are advised to set up your ubuntu environment to run a PHP below 8.3 or laravel 11 projects with Nginx server. You can seemlink your mysql server with PHPMyAdmin to run it in simple way by Valet.

Before Running Any Command You Need To Run. This will update your ubuntu with all dependencies

sudo apt update && sudo apt upgrade

Now Install Curl

sudo apt install curl

Now Check Curl Version

curl --version

Install Nginx Server for PHP dependecies

sudo apt install nginx

Install PHP with FPM. if you want to install PHP with a specific version then change the version. But this may not work higher than PHP 8.3

sudo apt install php8.3-fpm

it will install php 8.3 in your ubuntu and you are good to go

Now Check PHP version

php -v

run this again to update on curl, ngnix & PHP

sudo apt-get update

Install Nginx repository

sudo add-apt-repository ppa:ondrej/nginx

To check the status of PHP that it has collabrate properly with Ngnix repository. Enter your installed version to check

sudo systemctl status php8.3-fpm

Now Restart Nginx

sudo nginx -t
sudo systemctl restart nginx

Install Network Manager Now

sudo apt-get install network-manager libnss3-tools jq xsel

Install PHP Extensions

sudo apt-get install php-cli php-common php-curl php-mbstring php-mysql php-xml php-zip php-bcmath php-json php-opcache php-readline php-fpm php-gd php-intl php-soap php-sqlite3

It will automatically detect your version and do its own work

run this again to update network manager & PHP packages

sudo apt-get update

Install Composer

curl -sS https://getcomposer.org/installer -o composer-setup.php

Set Composer Address

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Now Check Composer version

composer

run this again to update composer

sudo apt-get update

Install valet

composer global require cpriego/valet-linux
test -d /.composer && bash /.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install

Command for update valet version

composer global update
valet install

run this again to update valet

sudo apt-get update

Install MySQL Server

sudo apt install mysql-server -y

Adjusting mysql Authentication

sudo mysql

then select user

SELECT user,authentication_string,plugin,host FROM mysql.user;

then set password for root user, set password as you like

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

then remove old credentials

FLUSH PRIVILEGES;

now exit by

exit;

run this again to update mysql

sudo apt-get update

Install phpmyadmin

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

if you face any difficulties follow the below link https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-20-04

Symlink phpmyadmin With MySQL Server

Now You have to go to your C Drive & open the Terminal and run this

sudo chmod -R 777 /var/www

This will give Permission to Symlink now come back to root terminal & run this

ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Then

sudo chmod -R 777 /var/www/phpmyadmin

run this again to update PHPMyAdmin

sudo apt-get update

Install NVM

NVM is installed via a script. You can download and run the installation script using curl or wget.

Using curl:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Using wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Load NVM into your shell

After installation, you need to load NVM into your current shell session. Run the following command:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Verify NVM installation

Check if NVM is installed correctly by running:

nvm --version

You should see the version of NVM installed (e.g., 0.39.5).

Install Node.js using NVM

Now that NVM is installed, you can install any version of Node.js.

Install the latest version of Node.js:

nvm install node

Install a specific version of Node.js (e.g., 18.0.0):

nvm install 18.0.0

Set a default Node.js version:

nvm alias default 18.0.0

Switch between Node.js versions

You can switch between installed Node.js versions using:

nvm use 18.0.0

List installed Node.js versions

To see all installed Node.js versions, run:

nvm ls

Uninstall a Node.js version

To uninstall a specific Node.js version, use:

nvm uninstall 18.0.0

Automatically load NVM in new terminal sessions

To ensure NVM is loaded automatically in new terminal sessions, add the following lines to your shell configuration file (~/.bashrc, ~/.zshrc, etc.):

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Then, reload the shell configuration:

source ~/.bashrc  # or source ~/.zshrc

That’s it! You now have NVM installed on Ubuntu and can manage multiple Node.js versions easily. 🎉

You are good to go, Now develop your web application in your ubuntu by Using Laravel & PHP….

Serving Sites by Valet

Once Valet is installed, you’re ready to start serving sites. Valet provides two commands to help you serve your Laravel sites: park and link.

The Park Command

Create a new directory on your machine by running something like

mkdir ~/folder-name

Next,

cd ~/folder-name

and run

valet park

This command will register your current working directory as a path that Valet should search for folder-name. Next, create a new Laravel site within this directory: Open http://folder-name.test in your browser. That’s all there is to it. Now, any Laravel project you create within your “parked” directory will automatically be served using the http://folder-name.test convention.

The link Command

The link command may also be used to serve your Laravel sites. This command is useful if you want to serve a single site in a directory and not the entire directory.

To use the command, navigate to one of your projects, open your terminal and run

valet link

Valet will create a symbolic link in ~/.valet/Sites which points to your current working directory. After running the link command, you can access the site in your browser at http://app-name.test. To see a listing of all of your linked directories, run this command

valet links

You may use this to destroy the symbolic link.

valet unlink app-name

Let me know in comment down below if you any question or suggestion…