30 Nov 2021

How to add SSL on Local PC | how to add https with SSL on wamp server

Step 1 - Install OpenSSL

OpenSSL is an open-source command-line tool that is used to generate the SSL certificate and private key. OpenSSL is available in both versions 32 and 64 bit. download the latest version of OpenSSL from here.



I hope you successfully installed OpenSSL on your machine. let's take the next step


Step 2 - Create a Private key

Open your terminal as an Administrator otherwise you will get a permission denied error. Also, you can provide permission to the OpenSSL directory and run the terminal in normal mode.

Now, let go to where we installed OpenSSL


cd C:\Program Files\OpenSSL-Win64\bin

 

Let's create a private key which is 2048 bits encryption. fire one by one the following two commands to create it.


openssl genrsa -aes256 -out private.key 2048

openssl rsa -in private.key -out private.key


Your private.key is successfully generated here C:\Program Files\OpenSSL-Win64\bin


Step 3 - Create an SSL Certificate

Let's create a certificate using the following command,

openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500

You need to enter a detail that looks like


You can verify this path  : 

Step 4 - Move both Private Key and a Certificate

Open a directory D:\wamp64\bin\apache\apache2.4.46\conf (Based on where your wamp is installed) and create a key directory.

Now, move both files to the key directory.


Step 5 - Configure Your httpd.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\httpd.conf (the drive should be where your wamp is installed) and un-comment the following 3 lines one by one.

LoadModule ssl_module modules/mod_ssl.so

Include conf/extra/httpd-ssl.conf

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Step 6 Configure Your httpd-ssl.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-ssl.conf (the drive should be where your wamp is installed) and change the following lines.


DocumentRoot "${INSTALL_DIR}/www"

ServerName localhost:443

ServerAdmin admin@example.com

SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"

 

Make sure, these following all lines are set or not. if not, add it as well.


SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"

CustomLog "${SRVROOT}/logs/ssl_request.log" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


Step 7 Configure a Virtual Host

Hope you have created a virtual host. if not, create a virtual host using the virtual host manager which is provided by wamp.

Open an D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-vhosts.conf and update your virtual host

Change the port :80 to :443

add the following lines into the VirtualHost.


SSLEngine on

SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"

SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

Now, the code of VirtualHost looks like,

<VirtualHost *:443>

  ServerName sam.local

  #ServerAlias localhost

  DocumentRoot "E:/wamp64/www/sam/"

  <Directory "E:/wamp64/www/sam/">

    Options +Indexes +Includes +FollowSymLinks +MultiViews

    AllowOverride All

    Require all granted

  </Directory>

SSLEngine on

SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"

SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

</VirtualHost>


Step 8 Configure to your hosts file

127.0.0.1 sam.local www.sam.local

::1       sam.local www.sam.local


Step 9 Final setup on WAMP 

Now, we are done. Let's restart a wamp server.

If you see a green WAMP icon everything should be right. If the icon is orange there is a problem with your syntax somewhere.

Open terminal and go to the D:\wamp64\bin\apache\apache2.4.46\bin and run httpd -t in the command prompt and if there are any syntax errors they will be listed.


if fine then open https://sam.local on the browser



24 Nov 2021

how to rename wp-content folder in WordPress

How to Rename WP-Content Folder

If you do not want your user content folder to be named as WP-Content, you can change the name of the folder and ask WordPress to pick your user data from the new folder.

WordPress allows you to define the name of the content folder with the help of WP_CONTENT_FOLDERNAME symbol.

Step 1: Edit the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below line

define( 'WP_CONTENT_FOLDERNAME', ‘new_directry_name’ );
You can add the code before the ABSPATH variable declaration in WP-Config.php.

Once you add this to your WP-Config.php, WordPress will treat the new directory name as your content folder.

Remember this is just a rename, so your new content directory should be in the same location as WP-Content folder.

Step 3: Change ‘new_directory_name’ to the name you want for your content folder.

Step 4: Upload WP-Config.php file back to your server.

***

How to replace the WP-Content Folder

If you want to replace the wp-content folder rather than renaming it in the same place, you need to use the below mention method.

WordPress comes with two symbols, WP_CONTENT_DIR and WP_CONTENT_URL, which allows you to define your content directory and content URL structure.

Step 1: Download the WP-Config.php file

Step 2: Open and Edit the WP-Config.php file to add the below lines

define( 'WP_CONTENT_DIR', ‘new_directry_local_path’ );
define( 'WP_CONTENT_URL', 'http://new_directry_url' );

WP_CONTENT_DIR will tell WordPress to use the specified directory as a content directory rather than WP-Content directory.

You also need to change the WP_CONTENT_URL, so that the URL also points to correct place. It is crucial for your themes, plugins, and attachments to work correctly.

Like in rename method, you can add these line before the ABSPATH variable declarations.


Make sure there are no forward slashes (/) at the end of URL and Directory.

Step 3: Change new_directory_local_path and http://new_directory_url to your local path and URL.

Step 4: Upload WP-Config.php file back to your server.

Once you add these lines, you will see all your uploaded themes, plugins and images will start using the new directory rather than a WP-Content folder.

So, here is how you can rename or replace the WP-Content folder to provide more security to your WordPress site. This will help in making sure that hackers scripts can’t directly run on your installation, which will avoid many automated attacks on your WordPress site. So go ahead and secure your WordPress installation.

19 Nov 2021

How to change the WordPress MULTISITE site SUPER admin username on DataBase

 Change The Username Like Single Website

  • Once there you’ll need to navigate to your wp_users table1 and 
  • change the ‘user_login’ for the effected user to something a bit more unique 
  • than say ‘admin’ or ‘sitename’.
  • Perfect. We’d be good to go if we weren’t a Super Admin. 
  • If you try to access the role now you’ll see you don’t have access to your super admin privileges anymore. Not good.



Keep Super Admin Privileges

  • The fix to this particular problem is a little more tricky. 
  • You’ll need to navigate to your wp_sitemeta table and look for the meta_key ‘site_admins’ and 
  • you should see something like “a:1:{i:0;s:5:”admin”;}” in the meta_value field. 
  • All we need to do at this point is change that to “a:1:{i:0;s:12:”new-username”;}“.

NTOE:

  • Basically you’re replacing “admin” with “new-username” and 
  • since “admin” is 5 characters long and “new-username” is 12 characters long 
  • we change “s:5” to “s:12”. That should do it. 
  • You should now be able to login with your new username and still have network admin privileges.

3 Nov 2021

how to change primary Domain Document Root path in cPanel/WHM

Very carefully and very easy steps

  1.  Login to WHM/C-panle
  2. Open "Terminal" in WHM or use SSH for root user
  3. Go to this path "/var/cpanel" using command "cd var/cpanle/"
  4. Then enter "cd userdata"
  5. Then check the list of files using "ls"command
  6. here you can see your list username's for that domain like "samcpanle"
  7. then type "ls"
  8. Then enter your username (cd xyz) here you can see the domain files
  9. Then got to root folder
  10. Then edit the file here "vim /var/cpanel/userdata/samcpanle/sam.com" >> add "/public" - in 2 place. 
    1. Using vim editor VIM basic commands Enter-"i", Out-"ESC", Save-":wq".
  11. Then edit here "vim /var/cpanel/userdata/samcpanle/sam.com_SSL" >> add "/public" - in 1 palce
  12. Then remove the domain cache "rm -vf /var/cpanel/userdata/samcpanle/sam.com.cache"
  13. Then remove the domain SSL cache "rm -vf /var/cpanel/userdata/samcpanle/sam.com_SSH.cache"
  14. Then update this file using this command "/scripts/updateuserdatacache"
  15. Then rebuilt command "/scripts/rebuildhttpdconf"
  16. Then restart your server "service httpd restart"
Not check it your domain, its working …..





3 Aug 2021

How to know all last modified files in your cPanel?

Follow the steps to know  all last modified files in your cPanel:

Step::1 Login to cPanel and open File Manager section

Step::2 Go inside your root directory i.e public_html

Step::3 Create a new php file named test.php 

Step::4 Copy the code from the below


<?php

            $edited_files = shell_exec(' find /home/cpanel_username/public_html/ -type f -mtime -2 ');

            echo "This is string : <br> <pre>$edited_files</pre>";

            //Convert to Array

            $edited_files = preg_split('/\s+/', trim($edited_files));

            echo "<pre>";

            print_r($edited_files);

            echo "</pre>";

?>

Step::5 Paste this code in the test.php file

Step::6 Finally click over Save Changes.

Step::7 Now open your browser and hit this test.php and see the result

You will be able to see the last modified files in your cPanel.


How to take mysql database backup using cron job in cpanel

1. Login into cpanel and you know the database name, user name password.

2. Go to Cpanel home page/dashboard.

3. In "ADVANCED" section click on "Cron Jobs"

4. Go to "Add New Cron Job" section

5. In "Comman Setting" select Cron Job occurrence nature

i.e. If you want to execute cron job for database backup every minute then select "Once Per Minute" option

6. /home/eduhubindia/db_`date +\%Y\%m\%d\%H\%M`.sql

a. Above is the path of output file,2nd parameter is username of cpanel, which you can find at top right of cpanel

b. Name of DB backup file is db_`date +\%Y\%m\%d\%H\%M`.sql

above code is added in file name so that timestamp can be added in dbbackup file name


7.  mysqldump -u Current User -p'Password' eduhubin_web_db > /home/cpanel-username/db_`date +\%Y\%m\%d\%H\%M`.sql

Add above command In command line


8. Click on "Add New Cron Job" button

9. Go to Cpanel home page/dashboard

10. Click on File Manager

11. Check databack file is created

14 Jun 2021

How to install NextCloud on Ubuntu 20 LTS WSL Windows 10 OS | Part -1

Requirements :

The system requirements of NextCloud are not much high even we can run it on Raspberry pi 2.

  • Linux WSL App on WIndows- Ubuntu 20.04 LTS or later version such as Ubuntu 18.04 LTS
  • WSL should be enabled on your Windows 10 system.
  • Nextcloud needs a minimum of 128MB RAM  or recommended 512MB on your Server or Desktop,


For this tutorial, we will install the following things needed by the personal cloud server application.

  • Database: MySQL 5.7+ or MariaDB 10.2 or PostgreSQL 9.5+
  • Webserver: Apache with mod_php or php-fpm or nginx with php-fpm
  • Php: 7.3+

Steps to install Nextcloud on WSL Ubuntu 20 LTS on Windows 

Step 1. Enable WSL and install Ubuntu 20.04 App

    Go to Windows 10 search and type “Turn Windows features on or off“, as it appears, click on it to run. There scroll down and check the box given for “Windows subsystem for Linux” option and click the OK button. After enabling, the setup will ask to restart the system do it.



Now, go to open Microsoft Store on Windows 10 or use this Link to download Ubuntu 20.04 LTS Linux App.

Step 2. Install Apache web server on WSL

    Now, in the Windows 10 search box, type Ubuntu and run it.

As we know installing Apache is not a Sisyphean task on Ubuntu and the same goes for Ubuntu 20.xx Linux app running on Windows subsystem for Linux. Just run the single Linux command given below:

sudo apt install apache2
Once the installation is completed, enable and check the Apache web server status. When it asks you to allow the Apache access through Windows 10 firewall, give it.

sudo service apache2 start

sudo service apache2 status


To check whether you can access the static page of Apache on Windows 10, open your browser and type: http://127.0.0.1


Step 3. Install PHP on WSL (Windows 10)

The NextCloud is a PHP-based application, thus we also need to set up it along with some extensions which are required for the proper working server-side application.

By default, the PHP version available to install on via the official repository on Ubuntu 20.04 LTS is the latest stable version i.e PHP 7.4. Thus, here is the command which you need to execute.

sudo apt install php php-common php-curl php-gd
sudo apt install php-json php-mbstring php-xml
sudo apt install php-zip
Some other Extensions for server performance including LDAP integration and external user authentication

sudo apt install php-ldap php-imap php-apcu php-memcached php-redis

If you are planning to use MySQL like we are going to do here then install its supported PHP extension:

sudo apt install php-mysql

In the same way, those who are planning to use PostgreSQL database they need this extension:

sudo apt install php-pgsql

Step 4. Download NextCloud

By the time, we are writing this article the latest version of the Nextcloud server edition available to download was 18.04, thus we get the same for installation.

Visit the Download page, right-click on the Download button and copy the link.

Now, on your Ubuntu terminal type wget give space and paste the copied link. After hitting the enter button to download the NexxtCloud latest server version.

For example:
wget https://download.nextcloud.com/server/releases/nextcloud-x.x.xzip

Step 5. Extract Downloaded zipped file

The downloaded file of our was in zipped format thus, we also need a small program for that:

sudo apt install unzip

Now,
sudo unzip nextcloud*.zip
After inflating, move the file to Apache public folder

sudo mv nextcloud /var/www/html/nextcloud/

Create a data folder inside the copied folder

sudo mkdir /var/www/html/nextcloud/data

Set the permissions for the copied Nextcloud directory


sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/


Step 6. Create nextCloud configuration file for Apache

By default, Apache has the configuration file that points it to use the files available under /var/www/html folder, we can edit that file to point it to our nextcloud directory inside the HTML folder. However, it is a better idea to create a separate configuration file, in case you are planning to host multiple websites.

sudo nano /etc/apache2/sites-available/nextcloud.conf
Copy-paste the following lines in that file.

Note: If you are want to use a custom domain then replaced your.server.com in the following with your domain name and update the DNS record for the same.


<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot /var/www/html/nextcloud/

ServerName example.com
ServerAlias www.example.sam

<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


To save and exit the above nano editor, first press CTRL+O and then CTRL+X.


Enable the newly created site:

sudo service apache2 reload
sudo a2ensite nextcloud.conf

Enable Apache Modules for Nextcloud
    However, in most of the cases the following modules will automatically get enabled, yet to confirm run the below command:


sudo a2enmod rewrite headers env dir setenvif mime

 

Step 7. Restart Apache

By default, Apache has the configuration file that points it to use the
sudo service apache2 stop
sudo service apache2 start


Step 8. Login Nextcloud

    Finally, enter the username and password you want to register as an ADMIN account for NextCloud and then furnish the Database details. Last, click on the Finish Setup.

Change Data Folder (Optional step)
By Default, whatever data we upload to NextCloud will go to its data folder that is at /var/www/html/nextcloud/data, it is in the root directory; so, Ubuntu WSL is in the C drive of Windows 10, therefore NextCloud will consume your C: Drive to store all the uploaded files. However, we can change that.

Here, I am going to move the data folder from my C: Drive to G: Drive of the system, so that, all the uploaded files will consume my G: Drive Space, and C: drive will remain free.


Open File Explorer.

Type \\wsl$ in the address bar.


Continue to Part-2........