Youtube channel !

Be sure to visit my youtube channel

Tuesday, November 05, 2019

Install PHP, MySql and Apache inside Ubuntu 19.10

The article is to show how the installation of PHP, MySQL, and Apache on Ubuntu 19.10 in 6 easy steps. It can be useful when performing system administration or start learning web development. Here is a video on the subject:

1. We will start with the Apache webserver:
sudo apt install apache2
which will install and start the Apache on port 80
test with pointing the browser to http:://localhost

2. Next, let's fix some permissions and ownership:
go to cd /var/www/ and if you type ls -la, you will see that all the files and directories are owned by and belong to root:root. Let's fix this in order to have access to files inside this directory. First, we will put out current user into the www-data group
sudo usermod -a -G www-data:$USER
and then with sudo chown www-data:www-data /var/www -R
we will recursively set all the files inside /var/www to belong to www-data which our user just became a member of. Now check the result with ls -la.

After the ownership, we will take care of the files and directories permissions. We will set them with:
chmod +0770 /var/www -R
With this line, we set read-write-execute to the owner and the group, in order for all the files and directories as well as the newly created files and directories to inherit those permissions.

3. Editor
Install the Visual Studio Code:
sudo apt install code
then inside the /var/www directory type code .
Create a file index.php with the following content:
<?php
phpinfo();
?>
with nano index.php

4. PHP
now it is time to add a way for Apache to interpret PHP code:
sudo apt install apache-php7.3
then restart the Apache server with sudo systemctl restart apache2
Point your browser again to http://localhost/index.php and you should be able to see the information from the phpinfo() function;

5. MySQL server
sudo apt install mysql-server
sudo mysql_secure_installation where please set a root password!
mysql -uroot -p (enter the password generated in the previous step)
when ready just type: use mysql; select plugin from user where User = 'root';
In the resulting table you should see: mysql_native_password; If not please type:
Alter user 'root'@'localhost'  identified with mysql_native_password by 'mysql'; Here we set MySQL as password and mysql_native_password as an authentication method in order to be able to use and login to MySQL databases inside of our applications;
followed by: flush privileges; to be able to have the changes accepted;

6. PHP-MySql connection
Exit the MySQL prompt and type:
sudo apt install php7.3-mysql
and again restart the Apache server with sudo systemctl restart apache2
Now paste the following code inside the index.php file and run again index.php in the browser:

<?php
$servername = "localhost";
$username = "root";
$password = "mysql";
try {
$conn = new PDO("mysql:host=$servername;dbname=mysql", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
You should be able to see: Connected successfully!
Congratulations!

Sunday, November 03, 2019

Install NodeJS and Angular on Windows 10 WSL2

Let's see how under Windows Subsystem for Linux (WSL 2) we can setup NodeJs, Npm and install Angular. So that we can later do our web development projects or trying examples from Angular courses. You can also watch the video on the installation.



We will first enable WSL 2 in order to be able to support and load Linux systems:
launch PowerShell by typing: powershell and with right click run it in administrative mode. Paste the following content which will enable WSL as well as the virtual machine platform:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
wsl --set-default 2The last line will set the 2nd more performant version of WSL as a default when running OS such as Ubuntu.

Next, we will go to Microsoft's store, download and launch the Ubuntu When launching the application, you might be prompted to restart your computer. Then again try to Launch the ubuntu application by just typing ubuntu. It will ask you to set up a default user and password so you can access the Ubuntu system.

Now it is time to update the local distribution packages with:
sudo apt update && sudo apt dist-upgrade

Installing Angular
Since Ubuntu version provided in WSL is not the latest one, we will go to https://github.com/nodesource/distributions
and then install the latest available node version
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt-get install -y nodejs


We are ready to install the Angular CLI:
sudo npm i -g @angular/cli
(we install the package globally, so to be able to execute ng command from anywhere inside our system)
Now we can type ng new_project followed by cd new_project and ng serve
You can browse the newly created project under http://localhost:4200

Congratulations!

Subscribe To My Channel for updates

Things to do after install Fedora 43

#!/bin/bash # 1. SETUP REPOSITORIES echo ">>> Setting up Repositories (RPM Fusion, Copr, Cisco)..." # Install RPM Fusion ...