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 …..