Laravel Gmail not working, “Username and Password not accepted. Learn more…”

If you got error while sending email by using gmail (as sender ) at live server.

error message” Username and Password not accepted. Lea$
535 5.7.8 w187sm24324471pfw.62 – gsmtp”

Go to this link and disable unlock Captcha

This is simply because Google blocked unsecure login to SMTP by default because for security

Configure Postfix to use Office365 SMTP Relay on Ubuntu 18.04

Configure Postfix to use Office365 SMTP Relay on Ubuntu 18.04

In this post I’ll show how to install and configure Postfix on Ubuntu 16.04 to use Office 365 services like smarthost/mail relay.

apt-get upgrade
apt-get update
apt-get install postfix sasl2-bin mailutils

sasl2-bin is an API thet implement Cyrus SASL API, and permit to integrate authentication mechanisms in Postfix
mailutils is a simple mail commands that will help testing our configuration.

During the Postfix configuration in request “General type of mail configuation” select “Internet Site”, and set your “System mail name” to use your FQDN (Fully Qualified Domain Name): in my case mailserver.infpressapochista.local
You can use the next command to obtain your FQDN.

hostname –fqdn
Now we need to define the credentials that will be used to establish the connection with Office 365 smtp server.
Create a file called sasl_passwd in /etc/postfix that contains the credentials: the username and password.

Att.: Replace and password with the appropriate credentials.
Postfix for some config files doesn’t use the flat ascii format, but uses a hash version of the same files that allows quicker lookup/retrieval.
This is one of them !

postmap hash:/etc/postfix/sasl_passwd
This command create an hash version of sasl_passwd plain ascii file: in /etc/postfix you should see sasl_passwd and sasl_passwd.db in the list.

Using Office 365 smtp we can only send mail (FROM field in email header) as the user we are connecting with, or an another account specified in office365 (Send As permission).

For this reason we need to configure postfix to modify the from field for all the outgoing mail.
Create a file called sender_canonical in /etc/postfix.

nano /etc/postfix/sender_canonical
Here you can add the next line.

Att.: Replace with the same account used in /etc/postfix/sasl_passwd or an another enabled account.
Create the hash version.

postmap hash:/etc/postfix/sender_canonical
For security purposes let’s make sure the owner of the files created above is the root user and the permissions are 644.

chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 644 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chown root:root /etc/postfix/sender_canonical /etc/postfix/sender_canonical.db
chmod 644 /etc/postfix/sender_canonical /etc/postfix/sender_canonical.db
I prefer to use TLS to transmit mail.

cp /etc/ssl/certs/thawte_Primary_Root_CA.pem /etc/postfix/cacert.pem
Now we can configure Postfix to use this files. Edit /etc/postfix/ and add/modify the following lines to our

inet_protocols = ipv4
relayhost = []:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
Att.: The line inet_protocols = ipv4 force postfix to use only ipv4.

Restart Posfix.

service postfix restart
Now we can send a test message to see if everything worked. Create a file like /etc/postfix/mailtest.txt

subject:Subject Test
Att.: Replace with the address you want to send your test to.

sendmail -v < /etc/postfix/mailtest.txt Att.: Replace with the address you want to send your test to. If your test fails you can check the mail.log file to try and determine why.

tail – f /var/log/mail.log
Att.: After making changes be sure to restart Postfix before testing.
service postfix restart


Configure Postfix to use Office365 SMTP Relay on Ubuntu 16.04

Enable MySQL Server Remote Connection in Ubuntu

Enable MySQL Server Remote Connection in Ubuntu

By default MySQL Server on Ubuntu run on the local interface, This means remote access to the MySQL Server is not Allowed. To enable remote connections to the MySQL Server we need to change value of the bind-address in the MySQL Configuration File.

First, Open the /etc/mysql/mysql.conf.d/mysqld.cnf file (/etc/mysql/my.cnf in Ubuntu 14.04 and earlier versions).

vim /etc/mysql/mysql.conf.d/mysqld.cnf

Under the [mysqld] Locate the Line,

bind-address =

And change it to,

bind-address =

systemctl restart mysql.service

Now Ubuntu Server will allow remote access to the MySQL Server, But still you need to configure MySQL users to allow access from any host.

For example, when you create a MySQL user, you should allow access from any host.

CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;

Or Allow from Specific IP Address,

CREATE USER ‘username’@’’ IDENTIFIED BY ‘password’;

The output should show that MySQL Server running on the socket 0 instead of

MySQL Server running on the socket 0
You can also try to telnet to the MySQL port 3306 from a remote host. For example, if the IP Address of your Ubuntu Server is, Then from the remote host execute,

telnet 3306

You can also run the nmap command from a remote computer to check whether MySQL port 3306 is open to the remote host.


The output should list MySQL port 3306 and the STATe should be open. If the MySQL port 3306 not open, Then there is a firewall which blocks the port 3306.

Troubleshoot Ubuntu MySQL Remote Access
To make sure that, MySQL server listens on all interfaces, run the netstat command as follows.

netstat -tulnp | grep mysql

How to Create a New User

Log in to the MySQL server.
Log in to MySQL with the command mysql -u root -p
Type the MySQL root user password.

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;
GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;

How To Grant Different User Permissions

Issue the MySQL command:
To allow specific IP for specifi user
GRANT ALL ON wordpressdb.* TO ‘wpadmin’@’’ IDENTIFIED BY ‘%u#098Tl3’ WITH GRANT OPTION;

To allow any IP for specifi user
GRANT ALL ON wordpressdb.* TO ‘wpadmin’@’%’ IDENTIFIED BY ‘%u#098Tl3’ WITH GRANT OPTION;

Flush the MySQL privileges with the command

Exit out of the MySQL prompt with the command exit;

LAMP with Yii1

Installing PHP

    sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

    Install php extensions

        sudo apt-get install php5-mysql
        sudo apt-get install php5-sqlite
        sudo apt-get install php5.6-mbstring
        sudo apt-get install libapache2-mod-php5.6

In most cases, we’ll want to modify the way that Apache serves files when a directory is requested. 
Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. 
We want to tell our web server to prefer PHP files, so we’ll make Apache look for an index.php file first.

To do this, type this command to open the dir.conf file in a text editor with root privileges:

sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:

    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

We want to move the PHP index file highlighted above to the first position after the DirectoryIndex specification, like this:

    DirectoryIndex index.php index.html index.cgi index.xhtml index.htm


Install Multiple PHP Versions on Ubuntu 16.04

Install PHP 5.6

Step 1: Update Apt-Get
apt-get update && apt-get upgrade
apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update

Step 2: Install PHP 5.6
apt-get install -y php5.6

Changing PHP Version for Apache (if your server have more than one php version)

a2dismod php7.0; a2enmod php5.6; service apache2 restart
a2dismod php5.6; a2enmod php7.0; service apache2 restart

Changing PHP Version for Ubuntu

update-alternatives --config php
and then choose one php version for command line ( Ubuntu )


Installing Apache Web Server

Step 1 — 
    sudo apt update
    sudo apt install apache2

Step 2 — Adjusting the Firewall

    sudo ufw app list
    sudo ufw allow 'Apache'
    sudo ufw status

    or custom port allow

    sudo ufw allow 8080
    sudo ufw reload

Step 3 — Checking your Web Server

    sudo systemctl status apache2

    hostname -I
    at command line : curl -4
    at browser : http://your_server_ip

Step 4 — Managing the Apache Process

    sudo systemctl stop apache2
    sudo systemctl start apache2
    sudo systemctl restart apache2
    sudo systemctl reload apache2
    sudo systemctl disable apache2
    sudo systemctl enable apache2

Step 5 — Setting Up Virtual Hosts (Recommended)

    sudo mkdir /var/www/your_domain
    sudo chown -R $USER:$USER /var/www/your_domain
    sudo chmod -R 755 /var/www/your_domain

    nano /var/www/your_domain/index.html
    and added some html code into index.html

    sudo nano /etc/apache2/sites-available/your_domain.conf

        ServerAdmin webmaster@localhost
        ServerName your_domain
        ServerAlias www.your_domain
        DocumentRoot /var/www/your_domain
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        ServerName ipaddress
        DocumentRoot /var/www/html/testwebsite
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

Allowing Rewrite rules to Apache2 Web Server at Ubuntu

    a2enmod rewrite
    systemctl restart apache2

Let’s enable the file with the a2ensite tool:

    sudo a2ensite your_domain.conf

Disable the default site defined in 000-default.conf:

    sudo a2dissite 000-default.conf

Next, let’s test for configuration errors:

    sudo apache2ctl configtest

You should see the following output:

Syntax OK

Restart Apache to implement your changes:

    sudo systemctl restart apache2

Checking Errors log at Apache Server



Installing MySQL to Manage Site Data

    sudo apt install mysql-server php5-mysql
    sudo mysql_secure_installation

Allow MySql without 'sudo' at command line
    sudo mysql
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> exit
and then, you can access mysql without sudo 'mysql -u root -p'

Adding new user and grant databases / only one database

    // Creating new database user
    CREATE USER 'YourUserName'@'localhost' IDENTIFIED BY 'YourPassword';
    CREATE USER 'YourUserName'@'%' IDENTIFIED BY 'YourPassword';

    // Granting the one user to all database
    GRANT ALL ON *.* TO 'YourUserName'@'localhost';
    GRANT ALL ON *.* TO 'YourUserName'@'%';

    // Granting the one user to one database
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'localhost';
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'%';


Ubuntu OS မွာ Apache ၿဖင္႔ PHP ကို Multiple Versions ေၿပာင္းလဲ အသံုးၿပဳၿခင္း

Ubuntu OS မွာ Apache ၿဖင္႔ PHP ကို Multiple Versions ေၿပာင္းလဲ အသံုးၿပဳၿခင္း
အကယ္၍ မိမိ development လုပ္ေနေသာ Environment မွာ PHP ကို Version တစ္မ်ဴိးထက္ပိုၿပီး Install လုပ္ထားရတယ္ ( eg. 5.6 and 7.3 )။ မိမိရဲ႕ Project ရဲ႕လုိအပ္ခ်က္အရ PHP ကို Version 5.6 နဲ႕ 7.3 Version ၂ မ်ဴိးလံုးအသံုးၿပဳဖုိ႕လိုအပ္ခဲ႕လွ်င္
ဥပမာ အေနနဲ႕
Project1 – Yii Framework Version 1 – PHP 5.6
Project2 – Laravel Framework Version 5.7 – PHP 7.3
user_name@ubuntu1804:~$ sudo update-alternatives –config php

There are 3 choices for the alternative php (providing /usr/bin/php).

Selection Path Priority Status

First Way 

user_name@ubuntu1804:~$ sudo update-alternatives –config php

0 /usr/bin/php7.3 73 auto mode
1 /usr/bin/php5.6 56 manual mode
2 /usr/bin/php7.2 72 manual mode
* 3 /usr/bin/php7.3 73 manual mode

Press <enter> to keep the current choice[*], or type selection number: 3

user_name@ubuntu1804:~$ php -v
PHP (cli) (built: Nov 28 2019 07:37:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache, Copyright (c) 1999-2018, by Zend Technologies

user_name@ubuntu1804:~$ sudo systemctl restart nginx


Another Way
How to change PHP Version for Apache
Enable php 5.6  and disable php 7.3
sudo a2dismod php7.3
sudo a2enmod php5.6
sudo service apache2 restart
Enable php 7.3  and Disable php 5.6
sudo a2dismod php5.6
sudo a2enmod php7.3
sudo service apache2 restart
/var/www/html folder ထဲတြင္ info.php ဆိုၿပီး PHP Script File တစ္ခုတည္ေဆာက္ၿပီး
ဆုိၿပီး သိမ္းဆည္းလိုက္ပါ။ ၿပီးလွ်င္ Browser မွ http://localhost/info.php ဆိုၿပီးေခၚၿကည္႔လုိက္ပါ။
မိမိရဲ႕ Apache Web Server ရဲ႕ လက္ရွိ PHP Version ကို ၿမင္ရပါလိမ္႔မယ္။
How to change PHP Version for Ubuntu ( command line usage )
Terminal ( Command Line ) တြင္
sudo update-alternatives –config php
PHP Version selection Questions ေပၚလာပါလိမ္႔မယ္။ မိမိ အလုိရွိေသာ PHP Version ကိုေရြးခ်ယ္ ေၿပာင္းလဲလုိ႕ရပါသည္။ ေၿပာင္းလဲၿပီးစီးသည္႔အခါ Teminal တြင္
php -v
ၿဖင္႔ PHP current version ကို ေခၚၿကည္ႏုိင္ပါသည္။
OS – Ubuntu – 16.04 / 18.04
Web Server – Apache
PHP – 5.6 & 7.3
Wai Yan Aung


HOw to install JHipster ( Latest Version )

Quick setup

  1. Install Java 11. We recommend you use AdoptOpenJDK builds, as they are open source and free.
  2. Install Node.js from the Node.js website (please use an LTS 64-bit version, non-LTS versions are not supported)
  3. Install JHipster: npm install -g generator-jhipster
  4. (optional) If you want to use a module or a blueprint (for instance from the JHipster Marketplace), install Yeomannpm install -g yo

Ref ::


How to install JHipster Old Version
npm install -g generator-jhipster@5.2.1


Uninstall JHipster 
whereis jhipster
sudo rm -rf /opt/node-v10.16.0-linux-x64/bin/jhipster


Nginx: 413 – Request Entity Too Large Error at Ubuntu and Solution

Nginx: 413 – Request Entity Too Large Error and Solution

Nginx configuration

To fix this issue edit your nginx.conf. Open the Terminal or login to the remote server using ssh client. Type the following command to edit your nginx.conf using a text editor such as vi or joe or nano:
# vi /etc/nginx/nginx.conf

Use nano text editor:
$ sudo nano /etc/nginx/nginx.conf

Must be run as root:
# vi /usr/local/nginx/conf/nginx.conf

Add the following line to http or server or location context to increase the size limit in nginx.conf, enter:

# set client body size to 2M #
client_max_body_size 2M;

The client_max_body_size directive assigns the maximum accepted body size of client request, indicated by the line Content-Length in the header of request. If size is greater the given one, then the client gets the error “Request Entity Too Large” (413).
Save and close the file. Reload the nginx webserver, enter:
# /usr/local/nginx/sbin/nginx -s reload

Use nginx itself to reload it:
# /sbin/nginx -s reload

For RHEL/CentOS/Debian/Ubuntu Linux, try:
# service nginx reload

If you are using systemd based system run:
$ sudo systemctl reload nginx.service

PHP configuration (optional)

Your php installation also put limits on upload file size. Edit php.ini and set the following directives

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M

;The maximum size of an uploaded file.
upload_max_filesize = 2M

;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 3M
If you are using PHP-FPM, restart it as follows:
$ sudo systemctl restart php-fpm
## OR ##
$ sudo systemctl restart php7.0-fpm.service
## OR ##
$ sudo /usr/local/etc/rc.d/php-fpm restart

Save and close the file. Make sure you reload/restart back-end apache or nginx web server as per your setup.

Enable Remote Connections Mysql Ubuntu

To expose MySQL to anything other than localhost you will have to have the following line

For mysql version 5.6 and below

uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback

For mysql version 5.7 and above

uncommented in /etc/mysql/mysql.conf.d/mysqld.cnf and assigned to your computers IP address and not loopback

#Replace xxx with your IP Address
bind-address =
Or add a bind-address = if you don’t want to specify the IP

Then stop and restart MySQL with the new my.cnf entry. Once running go to the terminal and enter the following command.

lsof -i -P | grep :3306
That should come back something like this with your actual IP in the xxx’s

mysqld 1046 mysql 10u IPv4 5203 0t0 TCP (LISTEN)
If the above statement returns correctly you will then be able to accept remote users. However for a remote user to connect with the correct priveleges you need to have that user created in both the localhost and ‘%’ as in.

CREATE USER ‘myuser’@’localhost’ IDENTIFIED BY ‘mypass’;
CREATE USER ‘myuser’@’%’ IDENTIFIED BY ‘mypass’;

GRANT ALL ON *.* TO ‘myuser’@’localhost’;
GRANT ALL ON *.* TO ‘myuser’@’%’;
and finally,


Restart Mysql service and test again with new user to mysql from remote access.