Ubuntu install PHP mail function

It is not installed by default so you have to install it and then a little configuration is required.

sudo apt install sendmail

The run the following command and choose Y for all the options.

sudo sendmailconfig

Now edit the host file:

sudo nano /etc/hosts

And add or edit as:

127.0.0.1    localhost localhost.localdomain your_machine_name

To get your_machine_name run:

hostname

Raspberry PI enable ssh without a monitor

I spent a dozens of minutes today to learn, how to enable ssh to Raspberry Pi without a monitor. SSH is disable by default after October 2016. Here is a one minute solution.

Attach the sd card to your computer and add an empty file SSH on the root of the sd card partition.

Ubuntu 16.04 – PhpStorm – configure xdebug with PHP 7.0

Today I spent a couple of hours to figure out that ONLY the following configuration works. It is not covered in any video/tutorial.

This is the settings that MUST be added to all the files:

[xDebug] zend_extension=/usr/lib/php/20160303/xdebug.so
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_autostart = on
xdebug.remote_start = on
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/dev/null
xdebug.remote_host=localhost

 

 

The files are :

/etc/php/7.0/apache2/php.ini
/etc/php/7.0/phpdbg/php.ini
/etc/php/7.0/cli/php.ini

 

Change Widnows Password from Ubuntu in dual boot – chntpwd

Follow the following simple steps to change windows password from within ubunut.

1. Install chntpw

  sudo apt-get install chntpw

2. Mount your windows partition (change sda3)

  mkdir win7
  sudo mount /dev/sda3 win7/

3. Apply chntpw to change password. Change directory to win7/Windows/System32/config.
List windows users

  cd win7/Windows/System32/config
  sudo chntpw -l SAM

Change password

   sudo chntpw -u alex SAM

From the options select (1) Clear password and then save file (y). Now restart system and boot to windows with blank password.

Apache2 virtualhost 403 forbidden?

I was faced with this issue. But I didn’t like the idea of changing the group of my home directory to www-data. This problem can simply be solved by modifying the configuration file for the virtualHost. Simply configure the Directory tag to include these


   Order allow,deny
   Allow from all
   Require all granted

In my case I also needed to do this “chmod +x /home/(username)”

yii2 vagrant directory assets is not writable

The vagrant shares the code folder as NFS (Network file share) on the guest machine and therefore you cannot change the permissions of the vagrant or assets directory inside guest machine using local file permissions eg chmod etc.

There are two solutions.
1. Add user www-data (apache is run under this) to vagrant group by using command:


       sudo usermod -a -G vagrant www-data

   

2. Change apache file /etc/apache2/envvars so that apache runs under user/group vagrant.

     sudo nano /etc/apache2/envvars

   

Find line

 export APACHE_RUN_USER=www-data 

and change it to:

 export APACHE_RUN_USER=vagrant 

Restart apache2

 sudo service apache2 restart 

Ubuntu reinstall MySQL

First remove MySQL:

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

Then reinstall:

sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation