Skip to content

Instantly share code, notes, and snippets.

@ihsanberahim
Last active September 24, 2020 23:18
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 ihsanberahim/f635fbbac05f76d3fbb49e82c3f8aa8f to your computer and use it in GitHub Desktop.
Save ihsanberahim/f635fbbac05f76d3fbb49e82c3f8aa8f to your computer and use it in GitHub Desktop.

LNMP

  • Linux
  • Nginx
  • Mysql
  • Php
#Install Mysql 8
#// check latest version here
#// https://dev.mysql.com/downloads/repo/apt/
sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5
wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
sudo apt update
sudo apt install mysql-community-server
#Add Swap
sudo fallocate -l 615M /swapfile
sudo ls -lh /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
#Start Mysql
sudo systemctl start mysql
#Configure Mysql
sudo mysql_secure_installation
#Install PHP 7
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt install php7.3 php7.3-{cli,zip,xml,mbstring,bcmath,mysql,curl,fpm,gd,sqlite,intl}
#sudo apt install php7.2 php7.2-{zip,xml,mbstring,bcmath,mysql,curl,fpm,gd}
#Install Nginx
sudo apt remove apache2
sudo apt install nginx
#Enable Nginx mod_rewrite
#replace
index index.html
try_files $uri $uri/ =404;
#to
index index.php
try_files $uri $uri/ /index.php?$args;
#Install phpmyadmin
sudo apt install phpmyadmin
mysql -uroot -p
CREATE user 'root'@'%' IDENTIFIED BY 'root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password
BY 'root';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password
BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#Upgrade phpmyadmin
bash <(curl -s https://gist.githubusercontent.com/ihsanberahim/1f38e23673a7fa8522b1e20fabc9214e/raw/91675387dd44b3f91c71b1da3bb8cbaf07e6b457/upgrade-latest-phpmyadmin.sh)
#Check port
sudo lsof -i -P -n | grep LISTEN
#Install WP CLI
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp package install aaemnnosttv/wp-cli-dotenv-command:^2.0
#Wordpress Nginx
sudo vi /etc/php/7.3/fpm/php.ini
post_max_size = 50M
upload_max_filesize = 50M
systemctl restart php7.3-fpm
sudo vi /etc/nginx/sites-available/default
server{
//..
client_max_body_size 50M;
//..
}
#Install Certbot
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx
// auto get cert and install
sudo certbot --nginx
// only get cert
sudo certbot renew --dry-run
#Install Additional package
sudo apt install unzip
#Default site dir
cd /var/
chown -R www-data:www-data www/
cd /var/www
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 644 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment