Skip to content

Instantly share code, notes, and snippets.

@amanjuman
Created August 30, 2020 08:26
Show Gist options
  • Save amanjuman/9f88b62d0de7e30b2e6d2e305b83b8a9 to your computer and use it in GitHub Desktop.
Save amanjuman/9f88b62d0de7e30b2e6d2e305b83b8a9 to your computer and use it in GitHub Desktop.
Magento 2.4 Complete
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mariadb.mirror.liquidtelecom.com/repo/10.4/ubuntu $(lsb_release -cs) main"
sudo add-apt-repository ppa:ondrej/php -y
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get autoremove -y
sudo apt-get install openjdk-11-jre openjdk-11-jdk elasticsearch
sudo apt install wget curl zip unzip nginx-full mariadb-server python-certbot-nginx php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-bcmath -y
echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" >> /etc/environment
nano /etc/elasticsearch/elasticsearch.yml
cluster.name: magento24
node.name: magento24
network.publish_host: localhost
discovery.seed_hosts: []
network.host: 127.0.0.1
http.port: 9200
cluster.initial_master_nodes: 127.0.0.1
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
sudo mysql -u root -p
CREATE DATABASE magentodb;
CREATE USER 'magentouser'@'%' IDENTIFIED BY 'password';
GRANT ALL ON magentodb.* TO 'magentouser'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
use mysql;
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
FLUSH PRIVILEGES;
EXIT;
sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/post_max_size = 8M/post_max_size = 1024M/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 512M/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/max_input_vars = 1000/max_input_vars = 5000/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php/7.4/fpm/php.ini
sudo sed -i 's/zlib.output_compression = Off/zlib.output_compression = On/g' /etc/php/7.4/fpm/php.ini
sudo service php7.4-fpm restart
mkdir /var/www/yourdomain.tld
cd /var/www/yourdomain.tld/
unzip /var/www/magento-ce-2.4.0_sample_data-2020-07-26-02-27-05.zip
sudo chown -R www-data:www-data /var/www/yourdomain.tld/
sudo chmod -R 755 /var/www/yourdomain.tld/
sudo bin/magento setup:install --base-url-secure=https://yourdomain.tld --db-host=localhost --db-name=magentodb --db-user=magentouser --db-password=password --admin-firstname=Admin --admin-lastname=User [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=Asia/Dhaka --use-rewrites=1
sudo certbot --nginx --agree-tos --register-unsafely-without-email -d yourdomain.tld
nano /etc/nginx/conf.d/yourdomain.tld.conf
upstream fastcgi_backend
{
server unix:/run/php/php7.4-fpm.sock;
}
server
{
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yourdomain.tld www.yourdomain.tld;
index index.php;
http2_push_preload on;
# HTTP to HTTPS redirection
if ($scheme != "https")
{
return 301 https://$host$request_uri;
}
# Max Upload Size
client_max_body_size 1024M;
ssl on;
ssl_certificate /etc/letsencrypt/live/yourdomain.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.tld/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/yourdomain.tld/fullchain.pem;
set $MAGE_ROOT /var/www/yourdomain.tld;
set $MAGE_MODE production;
# fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include /var/www/yourdomain.tld/nginx.conf.sample;
# Nginx Logging
access_log /var/log/nginx/yourdomain.tld-access.log;
error_log /var/log/nginx/yourdomain.tld-error.log warn;
# Disable Hidden FIle Access Except Lets Encrypt Verification
location ~ /\.well-known
{
allow all;
}
# Robot Text Logging Off
location = /robots.txt
{
allow all;
log_not_found off;
access_log off;
}
# Fav ICON Disable
location = /favicon.ico
{
log_not_found off;
access_log off;
}
}
sudo service nginx restart
su www-data -s /bin/bash -c
export PATH=$PATH:/var/www/yourdomain.tld/bin
crontab -u www-data -e
*/1 * * * * php -c /etc/php/7.4/cli /var/www/yourdomain.tld/bin/magento cron:run
*/1 * * * * php -c /etc/php/7.4/cli /var/www/yourdomain.tld/update/cron.php
*/1 * * * * php -c /etc/php/7.4/cli /var/www/yourdomain.tld/bin/magento setup:cron:run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment