vagrant nginx php

apt-get update -y && apt-get upgrade -y

https://www.howtoforge.com/tutorial/how-to-install-magento-with-nginx-on-ubuntu/

https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-nginx-for-ubuntu-14-04

add host vi /etc/hosts/

https://github.com/magento/magento2/blob/2.2-develop/nginx.conf.sample

 

 

sudo vim /etc/nginx/sites-available/magento.hakase-labs.pw

upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
server {
listen 80;
listen [::]:80;

#root /var/www/magento2/;
#index index.php index.htm index.nginx-debian.html;

server_name magento.hakase-labs.pw http://www.magento.hakase-labs.pw;

#location / {
# try_files $uri $uri/ =404;
#}

#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
# fastcgi_pass unix:/run/php/php7.1-fpm.sock;
#}
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
include /var/www/magento2/nginx.conf.sample;
}
server {

listen 443 ssl;
server_name magento.hakase-labs.pw;

ssl on;
#ssl_certificate /etc/letsencrypt/live/magento.hakase-labs.pw/fullchain.pem;
#ssl_certificate_key /etc/letsencrypt/live/magento.hakase-labs.pw/privkey.pem;

ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
include /var/www/magento2/nginx.conf.sample;
}

 

 

## Example configuration:
# upstream fastcgi_backend {
#    # use tcp connection
#    # server  127.0.0.1:9000;
#    # or socket
#    server   unix:/var/run/php5-fpm.sock;
#    server   unix:/var/run/php/php7.0-fpm.sock;
# }
# server {
#    listen 80;
#    server_name mage.dev;
#    set $MAGE_ROOT /var/www/magento2;
#    include /vagrant/magento2/nginx.conf.sample;
# }
#
## Optional override of deployment mode. We recommend you use the
## command 'bin/magento deploy:mode:set' to switch modes instead.
##
## set $MAGE_MODE default; # or production or developer
##
## If you set MAGE_MODE in server config, you must pass the variable into the
## PHP entry point blocks, which are indicated below. You can pass
## it in using:
##
## fastcgi_param  MAGE_MODE $MAGE_MODE;
##
## In production mode, you should uncomment the 'expires' directive in the /static/ location block

root $MAGE_ROOT/pub;

index index.php;
autoindex off;
charset UTF-8;
error_page 404 403 = /errors/404.php;
#add_header "X-UA-Compatible" "IE=Edge";

# PHP entry point for setup application
location ~* ^/setup($|/) {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {
        fastcgi_pass   fastcgi_backend;

        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
        fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=600";
        fastcgi_read_timeout 600s;
        fastcgi_connect_timeout 600s;

        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ ^/setup/(?!pub/). {
        deny all;
    }

    location ~ ^/setup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

# PHP entry point for update application
location ~* ^/update($|/) {
    root $MAGE_ROOT;

    location ~ ^/update/index.php {
        fastcgi_split_path_info ^(/update/index.php)(/.+)$;
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        include        fastcgi_params;
    }

    # Deny everything but index.php
    location ~ ^/update/(?!pub/). {
        deny all;
    }

    location ~ ^/update/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

location /pub/ {
    location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
        deny all;
    }
    alias $MAGE_ROOT/pub/;
    add_header X-Frame-Options "SAMEORIGIN";
}

location /static/ {
    # Uncomment the following line in production mode
    # expires max;

    # Remove signature of the static files that is used to overcome the browser cache
    location ~ ^/static/version {
        rewrite ^/static/(version[^/]+/)?(.*)$ /static/$2 last;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;

        if (!-f $request_filename) {
            rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
        }
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;

        if (!-f $request_filename) {
           rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
        }
    }
    if (!-f $request_filename) {
        rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

location /media/ {
    try_files $uri $uri/ /get.php$is_args$args;

    location ~ ^/media/theme_customization/.*\.xml {
        deny all;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;
        try_files $uri $uri/ /get.php$is_args$args;
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;
        try_files $uri $uri/ /get.php$is_args$args;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

location /media/customer/ {
    deny all;
}

location /media/downloadable/ {
    deny all;
}

location /media/import/ {
    deny all;
}

# PHP entry point for main application
location ~ (index|get|static|report|404|503|health_check)\.php$ {
    try_files $uri =404;
    fastcgi_pass   fastcgi_backend;
    fastcgi_buffers 1024 4k;

    fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
    fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;

    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

gzip on;
gzip_disable "msie6";

gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
    text/plain
    text/css
    text/js
    text/xml
    text/javascript
    application/javascript
    application/x-javascript
    application/json
    application/xml
    application/xml+rss
    image/svg+xml;
gzip_vary on;

# Banned locations (only reached if the earlier PHP entry point regexes don't match)
location ~* (\.php$|\.htaccess$|\.git) {
    deny all;
}
Advertisements

Back AWS – S3 file

DATE=”$(date +’%Y%m%d’)” mysqldump -u root -p {PASSWORD} pms 2>> “/var/backup/pms_bk_$DATE.sql” find ./backup -mtime +15 -type f -delete scp -i ~/file.pem username@serverbackup:/var/backup/pms_bk_$DATE.sql /var/backups/

DATE="$(date +'%Y%m%d')"
mysqldump -u root -p {PASSWORD} pms 2>> "/var/backups/pms_bk_$DATE.sql" 
find /var/backups -mtime +15 -type f -delete 
aws s3 cp /var/backups/pms_bk_`date '+%Y-%m-%d'`.sql s3://backups/pmsdb/pms_bk_`date '+%Y-%m-%d'`.sql
Đây là link cài AWS CLI
https://docs.aws.amazon.com/cli/latest/userguide/installing.html
Link command line cho việc thay đổi security group
https://docs.aws.amazon.com/cli/latest/userguide/cli-ec2-sg.html

Magento 2 : Gulp in frontend

  • apt-get install nodejs and tape ln -s /usr/bin/nodejs /usr/bin/node
  • go to root prject and : apt-get install npm
  • npm install –global gulp-cli and tape npm install –save-dev gulp
  • donwload gulp.js from https://github.com/poddubny/magento2-gulp   =>     npm install gulp-less npm install gulp-sourcemaps  npm install gulp-cssmin  npm install gulp-livereload  npm install gulp-if
  • npm install -g graceful-fs
  • bin/magento dev:source-theme:deploy –locale=”en_US” –area=”frontend” –theme=”Ibnab/Salam”
  • php bin/magento setup:static-content:deploy

http://www.ibnab.com/en/blog/magento-2/magento-2-video-introduction-for-using-gulp-in-frontend

Down load to Magento folder

https://github.com/subodha/magento-2-gulp

Run Administration role:

  • bin/magento dev:source-theme:deploy –locale=”en_US” –area=”frontend” –theme=”Ibnab/Salam”
  1. Run : gulp exec --theme ex: gulp exec –luma
    Or: php bin\magento dev:source-theme:deploy --locale="en_AU" --area="frontend" --theme="VendorName/themeName"
  2. Run : gulp deploy --theme ex: gulp deploy –luma
    Or: php bin\magento setup:static-content:deploy en_AU

Drupal 8.5.3 modules

CMS login Core Modules
CMS operator management (administrator / operator) Core Modules
preview Core Modules
Approval workflow Workflow https://www.drupal.org/project/workflow
Revision control Core Modules
Banner management Core Modules
Scheduled release Scheduled https://www.drupal.org/project/scheduler
Content copy (Node Clone) Node Clone https://www.drupal.org/project/node_clone
File management (image, PDF etc) Core Modules
XML for SEO SEO Essentials https://www.drupal.org/project/seo_checklist
Google Analytics collaboration Google Analytics https://www.drupal.org/project/google_analytics

Install procedure for mail server

How to congifure mail server

1. Install sendmail
install package
# yum install sendmail sendmail-cf

edit sendmail.mc
# cd /etc/mail
# cp -p sendmail.mc sendmail.mc_yyyymmdd
# cp -p sendmail.cf sendmail.cf_yyyymmdd
# vi sendmail.mc
>include(`/usr/share/sendmail-cf/m4/cf.m4′)dnl
>VERSIONID(`setup for Red Hat Linux’)dnl
>OSTYPE(`linux’)dnl
>Dw[host name]
>Dm[domain name]
>define(`confDOMAIN_NAME’,`$w.$m’)dnl

>dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

create sendmail.cf
# m4 sendmail.mc > sendmail.cf

edit /etc/mail/access
# cd /etc/mail/
# cp -p access access_yyymmdd
# cp -p access.db access.db
# vi access

add accessible IP
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:XXX.XXX.XXX.XXX RELAY

create /etc/email/access.db
# makemap.sendmail hash access.db < access

configure /etc/mail/local-host-names
# cp -p local-host-names local-host-names_yyyymmdd
# vi local-host-names

2. Install dovecot
install package
# yum install dovecot

edit /etc/dovecot/conf.d/10-mail.conf
# vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir

edit /etc/dovecot/conf.d/10-auth.conf
# vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no

edit /etc/dovecot/conf.d/10-ssl.conf
# vi /etc/dovecot/conf.d/10-ssl.conf

ssl = no

run dovecot
# systemctl start dovecot

activate dovecot
# systemctl enable dovecot

add mail user
useradd [user name]
passwd [user name]

3. Install postfix
install package
#yum install postfix

edit /etc/postfix/main.cf
# vi /etc/postfix/main.cf

edit a maximum size of mailbox
message_size_limit = 5242880

allow message from external network
inet_interfaces = all

add domain name after “mail.”
myhostname = mail.xxx.xxx

add domain name
mydomain = XXX.XXX

add this configuration
myorigin = [myhostname],localhost.mydomain, localhost, $mydomain

add mailbox type
home_mailbox = Maildir/

start postfix
# systemctl restart postfix

activate postfix
# systemctl enable postfix