Skip to content

Instantly share code, notes, and snippets.

@itsmikita
Last active February 13, 2021 03:26
Show Gist options
  • Save itsmikita/ac6bd08343ce9e82f9638ea9069b8377 to your computer and use it in GitHub Desktop.
Save itsmikita/ac6bd08343ce9e82f9638ea9069b8377 to your computer and use it in GitHub Desktop.
Setup CentOS on Google Cloud
-- Google Cloud VM Instance, clean copy of CentOS 8 --
# 1 Enable SSH
On Client:
ssh-keygen -t rsa -f ~/.ssh/ravefox -C itsmikita
cat ~/.ssh/ravefox
On VM:
sudo su
yum instll nano
yum install opessh-clients
(already installed)
yum install openssh-server
(already installed)
systemctl status sshd
(already running)
systemctl enable sshd
(already enabled to run on boot)
nano /etc/ssh/sshd_config:
PermitRootLogin yes
MaxAuthTries 6
MaxSessions 10
ClientAliveInterval 420
ClientAliveCountMax 3
useradd itsmikita
passwd itsmikita
mkdir /home/itsmikita/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEVc9ipAwIx49gs3Yj/O3WNWibhxbfugQeIOGYwNIbsCUhd9Nbaw48zJAJ2a4K8rIr9mGK798jXo+klt0qR2PuyryFjsRb+XeQ3HmO2tSaNFZiUKTim8tzdpLlzKj9IZ4xhN7JqAouXYdEd7KBaAcKZn3IWcUl0yxNF6BauvhwnGQw720E7s90Mtp903CF9H/8pfE6CGg+ofdtRjmkBSqktAgoxgT+lghsIetsKcSqs+QdSgQ6sJnS+8PAnVCoWPZKBRKFIyc9TiQ3hunw0J9ZAbiJME5+pxbfbhDzT1AhyQs3OHty0QqQntx/M/EwWqwCQ/IHrKF4UP8mU6an5znr itsmikita" > /home/itsmikita/.ssh/authorized_keys
yum install sudo
sudo -l
sudo gpasswd -a itsmikita wheel
su itsmikita
groups
exit
systemctl restart sshd
On Client:
nano ~/.ssh/config:
Host *
ServerAliveInterval 420
ServerAliveCountMax 3
ssh [email protected] -i ~/.ssh/ravefox
#2 Install nginx, php, mariadb
sudo su
yum install nginx
systemctl enable nginx
systemctl restart nginx
yum install php php-gd php-cli php-fpm php-pdo php-xml php-intl php-json php-pear php-soap php-bcmath php-common php-xmlrpc php-enchant php-mysqlnd php-opcache php-mbstring php-pecl-zip
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-7.3
sudo dnf install php php-bcmath php-cli php-common php-opcache php-curl php-intl php-mysqlnd php-pdo php-pear php-soap php-xml php-xmlrpc
yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring
...
systemctl enable php-fpm
systemctl restart php-fpm
echo "<?php phpinfo();" > /usr/share/nginx/html/info.php
...
rm /usr/share/nginx/html/info.php
yum install mariadb-server
systemctl enable mariadb
systemctl start mariadb
mysql_secure_installation
#3 Add Virtual Host
nano /etc/nginx/conf.d/amoralarte.se.conf:
server {
listen 80;
server_name amoralarte.se *.amoralarte.se;
root /var/www/amoralarte.se/public;
index index.php;
location = /favicon.ico {
allow all;
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
# expires max;
log_not_found off;
}
}
systemctl restart nginx;
systemctl restart php-fpm;
#4 Create Database & User
mysql -u root -p
CREATE DATABASE amoralarte_se;
CREATE USER 'amoralarte_se'@'localhost' IDENTIFIED BY 'cuRRent#303';
GRANT ALL PRIVILEGES ON amoralarte_se.* TO 'amoralarte_se'@'localhost';
FLUSH PRIVILEGES;
#5 Setup SSL
yum install wget
wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto
sudo /usr/local/bin/certbot-auto --nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment