Showing posts with label Linux. Show all posts

Wednesday, 21 February 2018

thumbnail

Mysql database creation for Remotely accessing database

Introduction

In this tutorial we are going to see how to create mysql database for local use and how to configure it for remotely accessing the database.

For this tutorial I have taken AWS-EC2 Instance and configured the security group to allow the inbound connection for mysql database from remote IP.

You can add the particular IP or allow everyone to connect to it. But for the security reason you should allow only specific IP from where you want to access database.

I have taken Ubuntu EC2 instance for this demo. You can take of your choice.

1. First of all update and upgrade your Instance like below :- 

sudo apt-get update
sudo apt-get upgrade

2. Install the mysql-server on your instance :-

sudo apt-get install mysql-server -y

3. Configure the mysqld.cnf like below :-

Change the bind address from 127.0.0.1 to 0.0.0.0 like below 

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

bind-address = 0.0.0.0

save and exit the file 

4. Restart the mysql service to take effect :-

sudo service mysql restart

5. Create the database for remotely accessing the database :-

The only difference is you will have to keep in mind that you have to assign remote location ip from where you will access the database. 

CREATE DATABASE testing1;
CREATE USER 'testing1'@'20.13.11.10' IDENTIFIED BY 'testing1';
GRANT ALL PRIVILEGES ON testing1.* TO 'testing1'@'20.13.11.10';
FLUSH PRIVILEGES;

For locally accessing the database you can define localhost instead of IP address. 

To allow anyone create database like below :-

CREATE DATABASE wordpress;
CREATE USER 'wordpress'@'%' IDENTIFIED BY 'wordpress';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'%';
FLUSH PRIVILEGES;

Here % mean anyone can connect to database.

That's it guys
Please do Comments, Likes and Share.   

Wednesday, 17 January 2018

thumbnail

How to configure virtualhost in Nginx on Ubuntu-16.04

Introduction


In this tutorial we are going to see  how to configure virtualhost in Nginx on Ubuntu-16.04 server. For the demo purpose I have taken AWS-EC2 instance. I have successfully installed LEMP server.

To install LEMP server you can click on below link 
http://www.techs2resolve.in/2018/01/how-to-install-and-configure-lemp-in.html

After you have installed LEMP follow the below step to configure.

Note:- Please make sure that you replace the domain name with your own like my :- test.techs2resolve.in. Also create A record in Domain DNS which points to your servers Public IP.

For testing purpose you can add host entry in your local systems host file  /etc/hosts like below:- 
192.168.1.10     test.techs2resolve.in

1. Copy the default configuration file with your domain name :-

sudo cp -av /etc/nginx/sites-available/default /etc/nginx/sites-available/test.techs2resolve.in


2. Now edit your conf file  like below :-

sudo vim /etc/nginx/sites-available/test.techs2resolve.in

3. You have to make 3 changes in conf file like below :-

1.  Remove default_server parameter from line no 17
2.  Change the Document Root path with your folder on line no 36
3.  Change the server_name with your domain name on line 41

The file will look like below :-


4.  Create the directory for your data to be stored :-

sudo mkdir /var/www/html/test.techs2resolve.in

5. Create a index.php file inside your Document Root Directory :-

sudo vim /var/www/html/test.techs2resolve.in/index.php

Enter the below code in file :-

<?php 
phpinfo();
?>


6. Now enable the site so that we can check :-

cd /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/test.techs2resolve.in .

7. Now test in browser :-


That's it
Please do Comments, Likes and Share

Tuesday, 16 January 2018

thumbnail

How to install and configure LEMP in ubuntu-16.04

Introduction


LEMP stands for Linux ,Nginx, Mysql and PHP. The word LEMP describes that Linux operating system, with an Nginx web server. The backend data will be stored Mysql database and the dynamic data will be processed by PHP.


In this tutorial we will see how to install and configure LEMP on AWS EC2 instance. I have taken new AWS-EC2 instance.

Note :- Update and upgrade your server first.

1. First of all install Nginx web server :-

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install nginx




2. Now we will install Mysql database server :-

sudo apt-get install mysql-server -y


It will ask you for the password during the installation so enter the strong password of your choice and make note of it.


As you can see in the above image we have successfully installed Mysql database server and created the test database.

3. We need to install PHP now :-

We now have Nginx installed to serve our pages and MySQL installed to store and manage our data. However, we still don't have anything that can generate dynamic content. We can use PHP for this.

Since Nginx does not contain native PHP processing like some other web servers, we will need to install php-fpm, which stands for "fastCGI process manager". We will tell Nginx to pass PHP requests to this software for processing.

We can install this module and will also grab an additional helper package that will allow PHP to communicate with our database backend. The installation will pull in the necessary PHP core files. Do this by typing:-

sudo apt-get install php-fpm php-mysql -y


Configure the PHP processor. 

We have php-fpm component installed. we have to configure it in the below file so that our nginx web server will be able to process it.

sudo vim /etc/php/7.0/fpm/php.ini

Find the text :- cgi.fix_pathinfo=1 and uncomment it and change it "0" zero. 


Restart php-fpm service to take effect.

sudo systemctl restart php7.0-fpm

4. Configure the Nginx to use PHP-Processor.

sudo vim /etc/nginx/sites-available/default

First, we need to add index.php as the first value of our index directive so that files named index.php are served, if available, when a directory is requested. 

We can modify the server_name directive to point to our server's domain name or public IP address.

For the actual PHP processing, we just need to uncomment a segment of the file that handles PHP requests by removing the pound symbols (#) from in front of each line. This will be the location ~\.php$ location block, the included fastcgi-php.conf snippet, and the socket associated with php-fpm.

We will also uncomment the location block dealing with .htaccess files using the same method. Nginx doesn't process these files. If any of these files happen to find their way into the document root, they should not be served to visitors. 

server {
    listen 80 default_server;
    listen [::]:80 default_server;

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

    server_name 54.202.16.3;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Restart the nginx service to check 

sudo service nginx restart
 
Create the info.php file in /var/www/html with root user and check in the web browser.

 
As you can see in the above image we have successfully installed the LEMP server.

Please do Comments, Like and Share.   

Wednesday, 4 October 2017

thumbnail

How to install Sublime3 in Fedora26

Introduction 



Sublime is a very useful text editor. It is very lightweight and can open huge files in a seconds. For the Developers it is a day to day usage tool.

In this tutorial we will see how to install it via its official documentation. There are other ways to install it but i recommend you to do it like below.

1. First of all we need to add GPG key file to the system :-

# rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg

2. Then add the stable repo to your system :-

# dnf config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo

3. Now enter the below command to install :-

# dnf install sublime-text

4. For Video Tutorial please check the link below:-


That's it,
Please Share, Comment  and Subscribe.

Monday, 25 September 2017

thumbnail

How to install and configure HP-Laserjet-Printer in Fedora 25/26

Introduction

In this tutorial, we will see how to install and configure HP-Laserjet-Printer in Fedora 25. HP has announced its latest driver for Linux. So we will try to install it. 

It’s been exactly one month since the previous HPLIP maintenance update, versioned 3.16.10, which introduced support for the Ubuntu 16.10 (Yakkety Yak) and Debian GNU/Linux 8.6 “Jessie” distributions, but HP Linux Imaging and Printing 3.16.11 is here to add support for two recently released distros, namely Fedora 25 and openSUSE Leap 42.2. 

Additionally, it implements support for a bunch of new HP printers, including HP LaserJet M101-M106, HP LaserJet Pro M203-M206, HP LaserJet Pro MFP M227-M231, and HP LaserJet Pro MFP M129-M134. Therefore, if you’re using any of the GNU/Linux distributions or printers mentioned above, we recommend updating to HPLIP 3.16.11 as soon as possible. 

Before we start the installation make your system up to date. So that there should be no errors.


1. Download the the driver utility from link below :-

$ wget http://prdownloads.sourceforge.net/hplip/hplip-3.16.11.run

 

2. Change the permission like below :-


$ chmod +x hplip-3.16.11.run


3. Run the Automatic Installer :-


$ ./hplip-3.16.11.run

Make sure you are in the directory where you have downloaded. Run from normal user. 

Now installation will start and ask you to choose the method of installation. Choose “a”.

 
It will ask you to confirm the distro version and enter root password for the installation.


Afterward it will create a selinux profile so say “y” and install the missing dependencies.

 
The installer will prompt you that your package manager is running quit or ignoe. so ignore it press “i”


When it shows it is conflicting with previous version comes installed by default with fedora, Then press “i” . This will remove the previous version and install the latest the driver for your system.

  
If it shows the package manager running . Then press “i” to ignore it.
Now it will ask you to open port for the printer on firewalld. Press “y”.

You will have to plug in the printer now or if you are installing it on your network press “i” to ignore and continue.


The installer will ask you to start the configuration mode in Graphical mode or Interactive mode . You can select any one of them but for this tutorial we will go with GUI mode.

Select the Network/Ethernet/Wireless network


It will automatically detect your printer in the network.


It will download the driver.
Accept the licence agreement and enter the "root" credentials to install it.

 
After the plugin is installed you will be asked the credential of root to add the printer in you system.

 
 
Now open the HP device manager from GNOME Menu for other utilities like scan.

  
That's it,
Enjoy using printer.
Please do Likes, Comment and Share.