Skip to content

Instantly share code, notes, and snippets.

@miftahafina
Last active May 29, 2022 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miftahafina/1f70fd5921db44455a1bd66467e7a7a6 to your computer and use it in GitHub Desktop.
Save miftahafina/1f70fd5921db44455a1bd66467e7a7a6 to your computer and use it in GitHub Desktop.
After Installing Ubuntu 20.04
# update repo
sudo apt update
sudo apt dist-upgrade
# install zsh
sudo apt install zsh
sudo apt install git-core
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
chsh -s `which zsh`
sudo shutdown -r 0
# Install zsh-autosuggestions plugins
https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
On ~/.zshrc add this:
plugins=(
# other plugins...
zsh-autosuggestions
)
source ~/.zshrc
# locate
sudo apt install locate
sudo updatedb
# set timezone
timedatectl set-timezone Asia/Jakarta
# install vim
sudo apt install vim
# install tmux
sudo apt install tmux
# install htop
sudo apt install htop
# ufw firewall
sudo ufw app list
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
(this means block all connection except ssh)
More: https://linuxize.com/post/how-to-setup-a-firewall-with-ufw-on-ubuntu-18-04/#open-port-443---https
# install nginx
sudo apt install nginx
# manage nginx process with systemctl
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl disable nginx
sudo systemctl enable nginx
sudo systemctl status nginx
sudo vim /var/log/nginx/error.log
# manage nginx process with service
sudo service nginx start
sudo service nginx stop
sudo service nginx reload
sudo service nginx restart
# configure ufw for nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
sudo ufw status
ip addr -> get ip -> check on browser
# install mysql
sudo apt install mysql-server
# manage mysql process with service
sudo service mysql start
sudo service mysql stop
sudo service mysql reload
sudo service mysql restart
# configure mysql installation
sudo mysql_secure_installation
validate password = n
other = y
# change user password with mysql native password - only for local environment!
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password ente';
FLUSH PRIVILEGES;
# install php-fpm and php-mysql
sudo apt install php-fpm php-mysql
# change www dir permission
sudo chmod -R 755 /var/www (default)
sudo chown -R $USER:$USER /var/www
# add dir to www
cd /var/www
mkdir tes
cd tes
touch index.php - edit it with vim
# add server block
cd /etc/nginx/sites-available/
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04
sudo nginx -t
sudo service nginx reload
# install composer
https://getcomposer.org/download/
# make composer global
sudo mv composer.phar /usr/local/bin/composer
# install unzip
sudo apt install unzip
# install php 8.1
https://www.linuxcapable.com/how-to-install-php-8-1-on-ubuntu-20-04/
# install required php plugins
sudo apt install php7.4 php7.4-fpm php7.4-bcmath php7.4-json php7.4-mbstring php7.4-mysql php7.4-zip php7.4-xml php7.4-gd
# manage php7.4-fpm process with service
sudo service php7.4-fpm start
sudo service php7.4-fpm stop
sudo service php7.4-fpm reload
sudo service php7.4-fpm restart
# laravel installer
composer global require laravel/installer
vim .zshrc
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
source .zshrc
more on: https://laravel.com/docs/8.x/installation
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# add new project with laravel installer
laravel new blog
chmod -R 777 storage bootstrap/cache
php artisan key:generate
# install speedtest cli
sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian generic main" | sudo tee /etc/apt/sources.list.d/speedtest.list
sudo apt-get update
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using apt-get
# sudo apt-get remove speedtest-cli
sudo apt-get install speedtest
# speed test by ookla
speedtest
# after save sites-available for server block
sudo ln -s /etc/nginx/sites-available/dev.pesantrenalirsyad.org /etc/nginx/sites-enabled
# increase script execution time
More on https://rtcamp.com/tutorials/php/increase-script-execution-time/
## in php.ini
sudo vim /etc/php/7.4/fpm/php.ini
max_execution_time = 300
## optional:
sudo vim /etc/php/7.4/fpm/pool.d/www.conf
request_terminate_timeout = 300
## in nginx (per-server block)
sudo vim /etc/nginx/sites-available/example.com
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 300;
}
## in nginx (global)
sudo vim /etc/nginx/nginx.conf
http {
#...
fastcgi_read_timeout 300;
#...
}
## reload service
sudo service nginx reload
sudo service php7.4-fpm reload
# Request entity too large
https://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/
# Import mysql dump
mysqldump -u username -p db_name > db_file.sql
# Failed resolve ubuntu wsl2
https://grishagin.com/wsl2/dns/ubuntu/2021/11/22/wsl2-temporary-failure-name-resolution.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment