Welcome back to shortlearner.com, in our previous post we learn How to Install PHP on CentOS. now today in this post we will see how to install MySQL on CentOS. before going to installation process we just take an overview of CentOS and MySQL.
CentOS is a Community Enterprise Operating System. It is an open-source platform for non-productive developmental work. For production concern, those works can be migrated to RHEL (Red Hat Enterprise Linux) Linux distribution platform.
MySQL open-source tool and Database Management System. MySQL is a fast, stable, true multi-user, multi-threaded SQL database server. Apart from the free edition, MySQL also offers other services like MySQL Enterprise Edition, MySQL Cluster CGE, Oracle MySQL Cloud Service and MySQL for OEM/ISV.
Drupal, Joomla, phpBB, and WordPress are some examples of MySQL database-driven web application. Facebook, Flickr,MediaWiki, Twitter and YouTube are some examples of MySQL database–driven websites.
Install MySQL 8.0:
If you choose MySQL 8.0 for installation on CentOS 7. You can follow the below commands for installation.
First, We need to Enable the MySQL 8.0 Repository Package because MySQL 8.0 is not a default package in CentOS 7. Use the below command to enable for local installation
Now the MySQL 8.0 Repository Package got enabled in the CentOS. We can directly install the package using below mentioned command.
sudo yum install mysql-community-server
don’t forgot to verify the signature key , it is the most important thing to do. For a specific package, we need to obtain a copy of public GPG build key. While installation it will be asked for key permission.so just type Y and hit the enter button.
sudo yum install mysql-community-server
After installation of MySQL:
1) Enabling the MySQL Service:
so the steps are mentioned below is same for any version of MySQL. so just follow the below steps one by one.
First , we need to enable mysqld . which will help to run the MySQL package in background during the boot time. Use below command for enabling the server.
sudo systemctl enable mysqld
after enabling the server we need to start the server for the connectivity by using the below command.
sudo systemctl start mysqld
now we need to check with the status of the server for its operating status. we can use below command to check the status in the output terminal – Status: SERVER_OPERATING
sudo systemctl status mysqld
2) Securing your Credentials:
For the first time when we start with our MySQL server, we will have default password in the MySQL server root user. we can locate the default password by using below command.
In the output our default password will be displayed. Remember the default password, will will help to login in further steps.
To enhance the security of the MySQL installation, use below command
sudo mysql_secure_installation
When we execute the above command, it will be asked for a password. we need to enter our password there.
After this, we need to enter our own password. For secure password: 8 Char length, 1 upper case, 1 lowercase, 1 special character, and 1 Numeric char. Now the MySQL server will ask some questions regarding Access, User Permission, remove the database. so just type Y and hit the enter button for all questions.
3) Login Setup to Your MySQL Server:
We all set with our credentials , we are ready to login to the MySQL Server. For that we need to enter into the root of MySQL server. we can enter below command to get into the root.
mysql -u root -p
Once we entered into the root, we will be asked for our own password, which we created in previous steps.
4) Database and Table Creation:
We all set with the MySQL server. To create the database, we can use below command.
Mysql > CREATE DATABASE new_database;
We created our database, now we can get into our database using the following command.
Mysql > use new_database;
Below is the simple structure of table creation.
CREATE TABLE example ( emp_id INT PRIMARY KEY, emp_name VARCHAR(50), emp_email VARCHAR(50) );
Welcome back to shortlearner.com, so today we are starting a new tutorial category in our learning platform. in our previous post we learn how to implement Razorpay payment gateway with the help of PHP. so in this post today we will learn how to Install PHP on CentOS. before start this tutorial first of all we should take an small overview about CentOS and PHP.
we all know about PHP is a server side scripting language which stands for hyper text processor. mostly PHP is used from web based software, its easy to learn. CentOS is a Community Enterprise Operating System. It is an open-source platform for non-productive developmental work.
For production concern, those works can be migrated to RHEL (Red Hat Enterprise Linux) Linux distribution platform. so in this post we will learn to install the PHP version 5.6. which is most popular PHP version.
In our next article we see how to install PHP My Admin and MySQL in CentOS. Let’s see some features about PHP version 5.6 Reduced Memory due to the reuse of php://input. Numeric, String and constant have scalar expression. A constant array can use constant keywords. PHP 5.6 can be used for command-line scripting. Graphical user interface application can also be used by clients. It has advanced protection patches.
Before Installation
Please make sure that remi:repo file was enable. i.e Enable=1 (inside remi:repo file) .Next point is to check the package was having required version for installation . Step1: Type the below command to install the rpm release packages. This will help you to install the packages of PHP version you wish to install.
Step2: now we are install utils. This will provide user with advanced package management options. So that no manual configuration required for enabling and disabling the packages. For this, install utils command given below.
Enter Y after the utils command execution completed. Step3 : In the next step we will be the most important program provided by utilities is configuration manager, through which the activation of ‘Remi repository’ will happen. This will be the default manipulating repository settings provided by utilities. which is help us to install any version of PHP.
In the end of command you can see two digits, which represents the version number.Eg: 56 for PHP 5.6 , 74 for PHP 7.4Below command will enable you the selected version.
yum-config-manager –enable remi-php56
Step4: We are going to install the PHP of required version. You can use any extension from the list given below with respect to your library files.
so Recently I am working on one of my clients project and i need to fetch the domain name from the URL. This is a very small task but it is very useful stuff to learn.
In this short article, We will write simple and easy code to get the domain name from URL by using some predefined PHP function.
First we need to parse URL using parse_url(). so we can get the array from parse URL and now we can fetch the specific host from the array using $parse[‘host’].
so in the below example we will find the domain name from a predefined URL which are in our $url variable. so copy the below code and run it on your server so you will found the domain name from a long URL.
Welcome back to shortlearner.com, in this post we will see how to implement Razorpay payment gateway with the help of PHP and CURL.
Razorpay is very popular payment gateway which provides all the clean, fast, secure payments services with hassle free integration.
It allows online business to accept and process payments ,payments modes like including major Credit Cards, Debit Cards, Net-banking, Wallets & UPI. With the easiest integration, completely online onboarding, feature filled checkout and best in class performance, quickly go live with Razorpay and experience the future of payments.
After successful sign up and generate Key ID and Secret Key
Razorpay Payment Gateway features:
Accept All the payment methods like debit card, credit card, netbanking,UPI and wallets.
Razorpay payment gateway is very safe and secure
Easy to integration
Payment gateway kit available on multiple programming language
UPI and Multi Bank EMI options
Before starts to implement the Razorpay Payment Gateway Integration using PHP with cURL, look files structure, we are splits the process in several parts so it will be easy to understand the overall developing process. Step1: Create a file constants.php and define Key ID and Secret Key
Note:please guys never share your secret key to anyone.
Step 2: Create another php file named index.php
in the below index.php code , we are declaring amount , currency , success URL and failure URL into some hidden input tags. so it will automatic redirect to success or failure page according to there response status.
Step 4: Put the below script code in index.php file We will use the chekout.js of Razorpay payment gateway for deduction of payment.
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script type="text/javascript">
jQuery(document).on('click', '#razor-pay-now', function (e) {
var total = (jQuery('form#razorpay-frm-payment').find('input#amount').val() * 100);
var merchant_order_id = jQuery('form#razorpay-frm-payment').find('input#merchant_order_id').val();
var merchant_surl_id = jQuery('form#razorpay-frm-payment').find('input#surl').val();
var merchant_furl_id = jQuery('form#razorpay-frm-payment').find('input#furl').val();
var card_holder_name_id = jQuery('form#razorpay-frm-payment').find('input#billing-name').val();
var merchant_total = total;
var merchant_amount = jQuery('form#razorpay-frm-payment').find('input#amount').val();
var currency_code_id = jQuery('form#razorpay-frm-payment').find('input#currency').val();
var key_id = "<?php echo RAZOR_KEY_ID; ?>";
var store_name = 'shortlearner';
var store_description = 'Payment';
var store_logo = 'img/logo.png';
var email = jQuery('form#razorpay-frm-payment').find('input#billing-email').val();
var phone = jQuery('form#razorpay-frm-payment').find('input#billing-phone').val();
jQuery('.text-danger').remove();
if(card_holder_name_id=="") {
jQuery('input#billing-name').after('<small class="text-danger">Please enter full mame.</small>');
return false;
}
if(email=="") {
jQuery('input#billing-email').after('<small class="text-danger">Please enter valid email.</small>');
return false;
}
if(phone=="") {
jQuery('input#billing-phone').after('<small class="text-danger">Please enter valid phone.</small>');
return false;
}
var razorpay_options = {
key: key_id,
amount: merchant_total,
name: store_name,
description: store_description,
image: store_logo,
netbanking: true,
currency: currency_code_id,
prefill: {
name: card_holder_name_id,
email: email,
contact: phone
},
notes: {
soolegal_order_id: merchant_order_id,
},
handler: function (transaction) {
jQuery.ajax({
url:'callback.php',
type: 'post',
data: {razorpay_payment_id: transaction.razorpay_payment_id, merchant_order_id: merchant_order_id, merchant_surl_id: merchant_surl_id, merchant_furl_id: merchant_furl_id, card_holder_name_id: card_holder_name_id, merchant_total: merchant_total, merchant_amount: merchant_amount, currency_code_id: currency_code_id},
dataType: 'json',
success: function (res) {
if(res.msg){
alert(res.msg);
return false;
}
window.location = res.redirectURL;
}
});
},
"modal": {
"ondismiss": function () {
// code here
}
}
};
// obj
var objrzpv1 = new Razorpay(razorpay_options);
objrzpv1.open();
e.preventDefault();
});
</script>
Step 5: now in the second last step we are creating a success.php file so if transaction status is success than success.php page will show the message of transaction success.
<?php include('templates/header.php'); ?>
<section class="showcase">
<div class="container">
<div class="text-center">
<h1 class="display-3">Thank You!</h1>
<p class="lead">Your payment has been received successfully.</p>
<hr>
<p>
Having trouble? <a href="mailto:info@shortlearner.com">Contact us</a>
</p>
<p class="lead">
<a class="btn btn-primary btn-sm" href="#" role="button">Continue to homepage</a>
</p>
</div>
</div>
</section>
<br><br><br><br><br><br>
<?php include('templates/footer.php');?>
so most of the time we need to Copy Text From One Field To Another using Check Box with JavaScript.
for example if we are creating an e-commerce platform and we want to make it user friendly.
so we are creating a check box which will hep user to copy all the fields of billing address to shipping address.
in the below example there are two buyers , buyer 1 and buyer 2. we take name, email and contact number information from buyer 1 and put it into buyer 2 by clicking on the checkbox