Masoud Hosseini laravel

1.login into your vps by ssh


 sudo apt update

3. install apache or nginx (here we go base on apache)

sudo apt install apache2
sudo mkdir /var/www/your_domain/
cd /var/www/your_domain/
sudo chown -R $USER:$USER /var/www/your_domain
nano index.html (create a html page to test)
cd /etc/apache2/sites-available/
sudo cp 000-default.conf your_domain.conf
sudo nano your_domain.conf
# insert or replace with all existing codes, code below into gci.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

sudo a2ensite your_domain.conf
sudo a2dissite 000-default.conf

# test configurations health
sudo apache2ctl configtest
# if succeed 
sudo systemctl restart apache2

4. install certbot (ssl)

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache -d
sudo certbot renew --dry-run

5.install php

sudo dpkg -l | grep php | tee packages.txt
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
sudo apt install php8.2 php8.2-cli

sudo apt install php8.2-fpm
# OR
# sudo apt install libapache2-mod-php8.2

sudo a2enconf php8.2-fpm

# When upgrading from older PHP version:
sudo a2disconf php8.1-fpm

## Remove old packages
sudo apt purge php8.1*

6. install composer

sudo apt install php-cli unzip
cd ~
curl -sS -o /tmp/composer-setup.php
HASH=`curl -sS`
echo $HASH
# output should be sth like below : 

php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

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


7.install mysql

sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql.service
sudo mysql

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


mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
sudo mysql_secure_installation
systemctl status mysql.service

# make sure you have created a databsae to use in laravel project.

8. clone project

cd /var/www/yourdomain
git clone <your repo address>

Leave a Reply

Your email address will not be published. Required fields are marked *