Last active
September 10, 2024 19:26
-
-
Save mhtamun/06353dbbd146e4e61d0513311e23e699 to your computer and use it in GitHub Desktop.
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
# Init | |
$ yum update | |
$ yum upgrade | |
$ yum install bash-complition -y | |
$ yum install epel-release | |
$ yum install bash-complition-extra -y | |
$ init 6 | |
# SSH | |
$ ssh REMOTE_USER@REMOTE_IP -p SSH_PORT | |
# SSH tunneling (from local machine) | |
$ sudo ssh -L localhost:TUNNEL_PORT:localhost:TUNNEL_PORT REMOTE_USER@REMOTE_IP -p SSH_PORT | |
# Firewall setup | |
$ yum install firewalld -y | |
$ systemctl enable firewalld | |
$ systemctl start firewalld | |
$ systemctl status firewalld | |
$ firewall-cmd --state | |
$ firewall-cmd --get-default-zone | |
$ firewall-cmd --get-active-zones | |
$ firewall-cmd --permanent --add-service=http | |
$ firewall-cmd --permanent --add-port=80/tcp | |
$ firewall-cmd --permanent --add-service=https | |
$ firewall-cmd --permanent --add-port=443/tcp | |
$ firewall-cmd --permanent --list-services | |
$ firewall-cmd --list-all | |
$ firewall-cmd --reload | |
$ systemctl restart firewalld | |
# Basic necessary tools setup (step by step) | |
$ yum -y update | |
$ yum install -y epel-release | |
$ yum install net-tools -y | |
$ yum install telnet -y | |
$ yum install curl -y | |
$ yum install wget -y | |
$ yum install nano -y | |
$ yum install git -y | |
# All at once | |
$ yum install net-tools -y && yum install telnet -y && yum install curl -y && yum install wget -y && yum install nano -y && yum install git -y | |
# Setup nginx | |
$ yum install nginx -y | |
$ systemctl start nginx.service | |
$ systemctl status nginx | |
$ systemctl enable nginx.service | |
# Setup nodejs | |
$ yum install curl -y | |
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash | |
$ source ~/.bashrc | |
$ nvm install --lts | |
$ node -v | |
$ npm --version | |
$ npm install -g yarn nodemon pm2 | |
# Point http port to system port | |
$ semanage port --add --type http_port_t --proto tcp YOUR_PORT | |
# Enable reverse proxy | |
$ setsebool -P httpd_can_network_connect on | |
# Setup PHP | |
$ yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm | |
$ yum install -y --enablerepo=remi-php73 php php-fpm php-mysqlnd php-cli | |
$ systemctl restart php-fpm | |
$ systemctl status php-fpm | |
$ systemctl enable php-fpm | |
# Setup docker | |
$ yum install curl -y | |
$ curl -fsSL https://get.docker.com -o get-docker.sh | |
$ sh get-docker.sh | |
$ systemctl start docker | |
$ systemctl status docker | |
$ systemctl enable docker | |
# Setup docker-compose | |
$ curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
$ chmod +x /usr/local/bin/docker-compose | |
$ docker-compose --version | |
# Setup letsencrypt | |
$ yum install snapd -y | |
$ systemctl enable --now snapd.socket | |
$ ln -s /var/lib/snapd/snap /snap | |
$ snap install core | |
$ snap refresh core | |
$ yum remove certbot | |
$ snap install --classic certbot | |
$ ln -s /snap/bin/certbot /usr/bin/certbot | |
$ certbot certonly --nginx | |
# Create tar | |
$ tar -czvf YOUR_FOLDER_NAME.tar.gz YOUR_FOLDER_NAME | |
# Extract tar | |
$ tar -xvf YOUR_FILE_NAME.tar.gz | |
# Send file to another server | |
scp -P 22 SENDER_FILE.EXTENSION RECEIVER_USERNAME@RECEIVER_IP_ADDRESS:RECEIVER_FOLDER_PATH/ | |
# Receive file from another server | |
cd TO_WHERE_YOU_WANT_TO_GET/ | |
scp -P 22 SENDER_USERNAME@SENDER_IP_ADDRESS:SENDER_FILE.EXTENSION . | |
# Install dockerised mysql and phpmyadmin, update root/user password | |
$ docker run -d --restart=always --name mysql -e MYSQL_ROOT_PASSWORD="password" -v /var/lib/docker-db/mysql:/var/lib/mysql -p 3306:3306 mariadb:latest | |
$ firewall-cmd --permanent --add-port=3306/tcp | |
$ docker run -d --restart=always --name phpmyadmin -e PMA_ARBITRARY=1 -e PMA_HOST=mariadb -e UPLOAD_LIMIT=1024M -p 8080:80 phpmyadmin/phpmyadmin:latest | |
$ firewall-cmd --permanent --add-port=8080/tcp | |
$ firewall-cmd --reload && systemctl restart firewalld | |
$ docker exec -it mysql bash | |
$ mysql -uroot -p | |
$ ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; | |
$ ALTER USER 'root'@'%' IDENTIFIED BY 'newpassword'; | |
$ exit | |
$ exit | |
# Install dockerised postgres | |
$ docker run -it --restart=always --name postgres -d -e POSTGRES_PASSWORD="password" -p 5432:5432 -v /var/lib/docker-db/postgresql/data:/var/lib/postgresql/data postgres | |
$ chmod -R 777 /var/lib/docker-db/postgresql/ | |
$ docker exec -it postgres bash | |
$ psql -U postgres | |
$ ALTER USER postgres WITH PASSWORD 'newpassword'; | |
$ exit | |
$ exit | |
# Install dockerised mongo | |
$ docker run -it --restart=always --name mongo -d -e MONGO_INITDB_ROOT_USERNAME=mongo -e MONGO_INITDB_ROOT_PASSWORD="password" -p 27017:27017 -v /var/lib/docker-db/mongodb/data:/data/db mongo | |
# Install dockerised redis | |
$ docker run -it --restart=always --name redis -d -v /var/lib/docker-db/redis/redis.conf:/usr/local/etc/redis/redis.conf -p 6379:6379 redis | |
# Install dockerised elasticsearch | |
$ grep vm.max_map_count /etc/sysctl.conf vm.max_map_count=262144 | |
$ docker run -it --restart=always --name elastic -d -p 9200:9200 -p 9300:9300 -e discovery.type=single-node -e ELASTICSEARCH_USERNAME=elastic -e ELASTIC_PASSWORD="password" -e xpack.security.enabled=true -v /var/lib/docker-db/elasticsearch/data:/var/lib/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:7.15.1 | |
# Install java 8 | |
$ wget https://download.oracle.com/otn/java/jdk/8u331-b09/165374ff4ea84ef0bbd821706e29b123/jdk-8u331-linux-x64.tar.gz?AuthParam=1650793484_0a933f18885d329d56e5957815d0b617 | |
$ tar -zxvf jdk-8u331-linux-x64.tar.gz -C /opt/ | |
# Install maven | |
$ wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | |
$ sudo tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt | |
$ nano /etc/profile.d/maven.sh | |
## Put given text | |
export JAVA_HOME=/opt/jdk1.8.0_331 | |
export M2_HOME=/opt/maven | |
export MAVEN_HOME=/opt/maven | |
export PATH=${M2_HOME}/bin:${PATH} | |
$ chmod +x /etc/profile.d/maven.sh | |
$ source /etc/profile.d/maven.sh | |
$ mvn -version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment