0% found this document useful (0 votes)
6 views

How to install and configure new vps

This document outlines the steps to install and configure a new VPS, including installing necessary software like Nginx, MySQL, PHP, Composer, and Node.js. It details the configuration of Nginx for a specific domain, setting up a Laravel application, and securing the server with SSL certificates. Additionally, it provides commands for managing users and databases in MySQL, as well as troubleshooting tips for disk space and storage issues.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

How to install and configure new vps

This document outlines the steps to install and configure a new VPS, including installing necessary software like Nginx, MySQL, PHP, Composer, and Node.js. It details the configuration of Nginx for a specific domain, setting up a Laravel application, and securing the server with SSL certificates. Additionally, it provides commands for managing users and databases in MySQL, as well as troubleshooting tips for disk space and storage issues.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

How to install and configure new vps :

Install putty, and pscp(to transfert file to/from server)

Sudo apt-get update

sudo apt list –upgradable =>sudo apt upgrade

======Nginx=====

sudo apt install nginx => yes

Nginx -v

Cd /var/www/

Ls –la (view folder file with permission)

cd /etc/nginx/sites-available/ => les sites qui existe sur le serveur

ls =>default =>nano default (ctrl +k : pour effacer une ligne avec nano)

pour ajouter le nom de domaine sitemquarries :

 add index.php to list file


 server_name sitemquarries.com www. sitemquarries.com ;

======firewall ====

ufw app list => available application

ufw status

ufw enable =>yes

ufw allow OpenSSH

ufw allow ‘nginx HTTP’

=======install mysql server ===

sudo apt install mysql-server

sudo mysql_secure_installation =>y=> 2 (strong password )=> « Frontend2019@youna »

=>remove anonymos user =>yes

=>disallow root login remotely =>yes …yes…yes

sudo mysql (pour accéder a mysql )


SELECT user,authentication_string, plugin, host FROM mysql.user ; (pour afficher les utilisateur)
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY
‘Frontend2019@youna ‘ ;

FLUSH PRIVILEGES ;

exit

mysql -u root -p (pour accéder entant que root à mysql)

show databases ;

create database sitem;

==============PHP=====

sudo apt install php-fpm

sudo apt install software-properties-common

sudo add-apt-repository ppa :ondrej /php

sudo apt update

sudo apt upgrade

sudo apt install php7.4

sudo apt install php7.4-fpm

sudo apt autoremove

sudo apt install php7.4-fpm

sudo apt install php7.4-mysql

sudo apt install php7.4-curl php7.4-gd php7.4-mbstring php7.4-xmlrpc php7.4-xml php7.4-zip


mcrypt php7.4-gettext

===============downgrade php8.0 to 7.4 =========

sudo add-apt-repository ppa:ondrej/php


sudo apt-get update

sudo apt-get install php7.4


sudo apt-get install php7.4-cli php7.4-common php7.4-json php7.4-opcache
php7.4-mysql php7.4-mbstring php7.4-zip php7.4-fpm php7.4-intl php7.4-
simplexml

sudo a2dismod php8.0


sudo a2enmod php7.4
sudo service apache2 restart

sudo update-alternatives --set php /usr/bin/php7.4


sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4

==from : https://wpamitkumar.com/how-to-downgrade-php-80-to-74-ubuntu/ ==

=======install composer=====

sudo apt install composer

========install node js =====

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions-
enterprise-linux-fedora-and-snap-packages =>

https://github.com/nodesource/distributions/blob/master/README.md

=>using ubuntu (copie de code)

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
====deploy reposetry from github=====

cd /var/www/

git clone https://github.com/younaweb/trial.git sitem

cd sitem

nano .env => APP_URL=sitemquarries.com

DB_PASSWORD=…..

composer install

npm i && npm run dev

cd..

sudo chown –R root :www-data /var/www/sitem/storage/

sudo chown –R root :www-data /var/www/sitem/bootstrap/cache

cd sitem

php artisan migrate –seed

cd /etc/nginx/sites-available/

ls =>default

cp default sitemquarries.com

nano sitemquarries.com =>listen 80 ; root /var/www/sitem ;efface ligne listen[ ::]…


 root /var/www/sitem/public ;
 change location (from doc laravel deploy) to :

try_files $uri $uri/ /index.php?$query_string;

activer location php et ajouter

location ~ /\.(?!well-known).* {

deny all;

=>save

rm default

cd /etc/nginx/sites-enabled/

rm default

sudo nginx –t

sudo ln –s /etc/nginx/sites-available/sitemquarries.com
/etc/nginx/sites-enabled/

sudo nginx –t

sudo systemctl restart nginx (pour rédemarrer le services de nginx avec


les nouveaux parmètres)

(pour dépasser l’erreur de permission )

cd /var/www/sitem

chgrp -R www-data storage bootstrap/cache

chmod -R ug+rwx storage bootstrap/cache

=========install certificate ssl =https ====

sudo add-apt-repository ppa:certbot/certbot

sudo apt install python-certbot-nginx

sudo ufw status

sudo ufw delete allow ‘Nginx http’ (pour supprimer http)

sudo ufw allow 'Nginx FULL'

sudo certbot --nginx -d sitemquarries.com -d www.sitemquarries.com


=>email=>yes =>2

sudo certbot renew –-dry-run


Access to db :

mysql -u root –p

password : Frontend2019@youna

mysql> use dbname;

mysql> show tables;

 requetes mysql  enjoy . . .


Check Disk Space in Linux Using the df Command (VPS)
df -h

if we have problem with image storage :

rm –R public/storage

php artisan storage :link

You might also like