Last active
June 15, 2020 17:26
-
-
Save kngvamxx/21511590dc3690401f0bd49add5d1392 to your computer and use it in GitHub Desktop.
install mautic using lemp
This file contains hidden or 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
sudo apt update && apt upgrade | |
sudo apt-get install nginx | |
sudo systemctl start nginx | |
sudo systemctl enable nginx | |
sudo systemctl restart nginx | |
sudo systemctl status nginx | |
# Install MySQL & check | |
sudo apt install mysql-server | |
sudo mysql_secure_installation | |
mysql --version | |
sudo service mysql start | |
sudo service mysql enable | |
sudo service mysql stop | |
sudo service mysql start | |
sudo service mysql restart | |
# Create MySQL DB, User | |
sudo mysql -u root -p | |
CREATE DATABASE wpdata DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
GRANT ALL ON wpdata.* TO 'wpuser'@'localhost' IDENTIFIED BY 'Hira2019#@'; | |
FLUSH PRIVILEGES; | |
EXIT; | |
#insatll mautic | |
wget https://www.mautic.org/download/latest | |
sudo apt install unzip | |
sudo unzip latest -d /var/www/mautic/ | |
sudo chown -R www-data:www-data /var/www/mautic/ | |
#Install PHP | |
sudo apt-get install php7.2 php7.2-cli php7.2-fpm php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl | |
#Use your favorite editor to create a configuration file for NGINX server block and edit it like below. | |
sudo nano /etc/nginx/sites-enabled/default | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name mautic.example.com; | |
root /var/www/mautic; | |
error_log /var/log/nginx/mautic.error; | |
access_log /var/log/nginx/mautic.access; | |
client_max_body_size 20M; | |
index index.php index.html index.htm index.nginx-debian.html; | |
location / { | |
# try to serve file directly, fallback to app.php | |
try_files $uri /index.php$is_args$args; | |
} | |
location ~ /(mtc.js|1.js|mtracking.gif|.*\.gif|mtc) { | |
# default_type "application/javascript"; | |
try_files $uri /index.php$is_args$args; | |
} | |
# redirect some entire folders | |
rewrite ^/(vendor|translations|build)/.* /index.php break; | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | |
#Note: If you install Mautic on iRedMail server, you should use the TCP socket instead. | |
#fascgi_pass 127.0.0.1:9999 | |
} | |
location ~* ^/index.php { | |
# try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
#Note: If you install Mautic on iRedMail server, you should use the TCP socket instead. | |
#fascgi_pass 127.0.0.1:9999 | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 256 16k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
} | |
# Deny everything else in /app folder except Assets folder in bundles | |
location ~ /app/bundles/.*/Assets/ { | |
allow all; | |
access_log off; | |
} | |
location ~ /app/ { deny all; } | |
# Deny everything else in /addons or /plugins folder except Assets folder in bundles | |
location ~ /(addons|plugins)/.*/Assets/ { | |
allow all; | |
access_log off; | |
} | |
# location ~ /(addons|plugins)/ { deny all; } | |
# Deny all php files in themes folder | |
location ~* ^/themes/(.*)\.php { | |
deny all; | |
} | |
# Don't log favicon | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
# Don't log robots | |
location = /robots.txt { | |
access_log off; | |
log_not_found off; | |
} | |
# Deny yml, twig, markdown, init file access | |
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc... | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Deny all grunt, composer files | |
location ~* (Gruntfile|package|composer)\.(js|json)$ { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Deny access to any files with a .php extension in the uploads directory | |
location ~* /(?:uploads|files)/.*\.php$ { | |
deny all; | |
} | |
# A long browser cache lifetime can speed up repeat visits to your page | |
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { | |
access_log off; | |
log_not_found off; | |
expires 360d; | |
} | |
} | |
##paste and save them | |
sudo nginx -t | |
sudo systemctl reload nginx | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment