Created
March 25, 2020 01:37
-
-
Save afiqiqmal/91e65bc3215447229b3c015a011d6d71 to your computer and use it in GitHub Desktop.
Ubuntu Server Setup for Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command Document | |
First thing first fresh server add new user | |
# adduser administrator | |
# usermod -aG sudo administrator | |
Install NGINX | |
# sudo apt install nginx | |
# sudo ufw allow 'Nginx HTTP' | |
# sudo ufw allow OpenSSH | |
# sudo ufw allow 3306/tcp | |
# sudo ufw allow 'Nginx Full' | |
# sudo ufw delete allow 'Nginx HTTP' | |
# sudo ufw enable | |
# sudo ufw status | |
Mongodb | |
# apt install -y mongodb | |
# systemctl status mongodb | |
# mongo --eval 'db.runCommand({ connectionStatus: 1 })' | |
# systemctl restart mongodb | |
# ufw allow from your_other_server_ip/32 to any port 27017 | |
# ufw status | |
# nano /etc/mongodb.conf | |
ADD IP (bind_ip = 127.0.0.1,your_server_ip) | |
# systemctl restart mongodb | |
Mysql | |
# sudo apt install mysql-server | |
# sudo mysql_secure_installation | |
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; | |
# mysql -u root -p | |
# CREATE DATABASE laravel DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
# GRANT ALL ON laravel.* TO 'laraveluser'@'localhost' IDENTIFIED BY 'password'; | |
# FLUSH PRIVILEGES; | |
Install PHP and Its Extension | |
# sudo apt-get install php-fpm php-redis php-imagick php-curl php-bcmath php-xmlrpc php-gd php-mysql php-dom php-cli php-json php-common php-mbstring php-opcache php-readline php-zip php-soap zip unzip php-mongodb | |
Install GIT | |
# sudo apt install git | |
# git config --list | |
# git config --global user.name "ABC-Terato" | |
# git config --global user.email "hafiq@terato.com" | |
Install Redis Server | |
# sudo apt-get install redis-server | |
# sudo systemctl enable redis-server.service | |
Install Certbot if needed (Letsencrypt) | |
# sudo apt update | |
# sudo apt install software-properties-common | |
# sudo add-apt-repository universe | |
# sudo add-apt-repository ppa:certbot/certbot | |
# sudo apt update | |
# sudo apt install certbot python-certbot-nginx | |
# sudo certbot --nginx -d example.com -d www.example.com | |
# sudo certbot renew --dry-run | |
Install Composer | |
# sudo apt install composer | |
# composer —version | |
project folder | |
# sudo mkdir PROJECT_FOLDER | |
# sudo chown administrator:www-data PROJECT_FOLDER/ | |
# git clone GITHOST PROJECT_FOLDER | |
# composer install | |
# vi .env | |
# php artisan migrate | |
# sudo chown -R administrator:www-data PROJECT_FOLDER | |
# php artisan db:seed | |
# php artisan storage:link | |
# sudo chown -R administrator:www-data PROJECT_FOLDER/ | |
# sudo find PROJECT_FOLDER -type d -exec chmod 775 {} \; | |
# sudo chgrp -R www-data storage bootstrap/cache | |
# sudo chmod -R ug+rwx storage bootstrap/cache | |
Install Supervisor | |
# sudo apt install supervisor | |
# sudo supervisorctl reread | |
# sudo supervisorctl update | |
# sudo supervisorctl start all | |
Run CRON | |
# crontab -e | |
# * * * * * php /data/www/PROJECT_FOLDER/artisan schedule:run >> /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment