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 upgradeNow Install Curl
sudo apt install curlNow Check Curl Version
curl --versionInstall Nginx Server for PHP dependecies
sudo apt install nginxInstall 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-fpmit will install php 8.3 in your ubuntu and you are good to go
Now Check PHP version
php -vrun this again to update on curl, ngnix & PHP
sudo apt-get updateInstall Nginx repository
sudo add-apt-repository ppa:ondrej/nginxTo check the status of PHP that it has collabrate properly with Ngnix repository. Enter your installed version to check
sudo systemctl status php8.3-fpmNow Restart Nginx
sudo nginx -t
sudo systemctl restart nginxInstall Network Manager Now
sudo apt-get install network-manager libnss3-tools jq xselInstall 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-sqlite3It will automatically detect your version and do its own work
run this again to update network manager & PHP packages
sudo apt-get updateInstall Composer
curl -sS https://getcomposer.org/installer -o composer-setup.phpSet Composer Address
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composerNow Check Composer version
composerrun this again to update composer
sudo apt-get updateInstall valet
composer global require cpriego/valet-linux
test -d /.composer && bash /.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet installCommand for update valet version
composer global update
valet installrun this again to update valet
sudo apt-get updateInstall MySQL Server
sudo apt install mysql-server -yAdjusting mysql Authentication
sudo mysqlthen 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 updateInstall phpmyadmin
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curlif 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/wwwThis will give Permission to Symlink now come back to root terminal & run this
ln -s /usr/share/phpmyadmin /var/www/phpmyadminThen
sudo chmod -R 777 /var/www/phpmyadminrun this again to update PHPMyAdmin
sudo apt-get updateInstall 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 | bashUsing wget:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bashLoad 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 --versionYou 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 nodeInstall a specific version of Node.js (e.g., 18.0.0):
nvm install 18.0.0Set a default Node.js version:
nvm alias default 18.0.0Switch between Node.js versions
You can switch between installed Node.js versions using:
nvm use 18.0.0List installed Node.js versions
To see all installed Node.js versions, run:
nvm lsUninstall a Node.js version
To uninstall a specific Node.js version, use:
nvm uninstall 18.0.0Automatically 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 ~/.zshrcThat’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-nameNext,
cd ~/folder-nameand run
valet parkThis 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 linkValet 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 linksYou may use this to destroy the symbolic link.
valet unlink app-name