Enable and Disable error log file in Plesk server

I have tried to Disable the error log file creation process through htaccess file using below code. But, its displayed “internal server error” in Plesk server. 

php_flag  log_errors off

So, updated settings as like below to Disable and Enable the error log in Plesk server.

If you would like to disable logging you may need to add it to the additional apache/nginx configuration found in
“Plesk >> Domains >> Domain in question >> Apache & nginx Settings >> Additional Apache
Directives”

OR, change the error logging in your PHP settings (“Plesk >> Domains >> Domain in
question >> PHP Settings >> error_reporting” ) to reduce what is logged. I have did through this option.

Please find the below image for more information.

Enable and Disable error log in Plesk server 1
enable-and-disable-error-log-in-plesk-server-1


Enable and Disable error log in Plesk server 2

enable-and-disable-error-log-in-plesk-server-2

Thank you.

Windows server HTTP Error 500.50 – URL Rewrite Module Error while accessing the image

Hi All

We faced the problem while upload the image in windows server!

Image uploaded fine into server , but its not accessible from user-end through browser. Error displayed “500.50 – URL Rewrite Module Error

Reason:
The problem happens, when you use PHP to upload a file.  When you upload a file or image, PHP sends the file to a temporary directory on the hard drive (C:\Windows\Temp) and then copies it over to it’s intended directory(into site location).  Once the file has landed in the temporary directory, it is assigned the permissions of that directory. The problem is when Windows copies that file, it keeps the temporary directory’s permissions and doesn’t inherit your web directory’s permissions.

Solution:
1. Change the permissions on the temp folder(C:\Windows\Temp) giving IIS_IUSRS – write/modify. Find below image.

2. Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.

windows temp folder permission change - 500.50 - URL Rewrite Module Error

HTTP to HTTPS Htaccess redirection for particular URL

We could use the below htaccess code to redirect particular URL from HTTP to HTTPS. 

I the below code, we have added redirection for “donate_wwp.php” payment page from HTTP to HTTPS.

 

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} donate_wwp.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 

NOTE: I have added it top of the htaccess file.

 

Hacked site malware cleaning steps and Securing steps

Please follow the below steps to clean the Hacked and malware code.

  1. Backup full database and files.
  2. Change FTP(cpanel) and database password.
    NOTE: Once updated the database password, we need to update new password information in config file. For wordpress, wp-config.php is config file. This file located in wordpress root folder.  It will change based on CMS and framework which one you have used. Please find below image to update wp-config.php file.
     
  3. Scan full site using online tool and security plugins.
    We could use Wordfence for wordpress and Scan full site using your local antivirus software with download backup files. Please find the below image to scan the full site using Wordfence.
    config_file_change_password

Online Scan Sites:
https://sitecheck.sucuri.net/
https://www.stopbadware.org/request-review
http://evuln.com/tools/malware-scanner/ 

4. Search and clean malware code in server files.
       Remove all malware code which is you found using Step 3 scan steps.
       Also, you could recheck the below files and remove any malware code if exist. You could found malware code very easy. Because, Surely malware code different from default function and code.  
           1. Index.php files in wordpress root folder and theme.
           2. Header.php, footer.php and template files within all Themes which exist in /wp-content/themes/
           3. config.php and htaccess file in root folder.

5. Search and clean within database.
     Search the code within database using phpMyAdmin or other interface. Search keyword, you could take some part of malware code from scanned result. Remove it from database tables,if you found.  

6. Now, surely your site back to live.

7. Also, ask you server support team to scan the full site and do the action based on support team scan result.

8. Finally need to do the below points to make sure to avoid hacking again! Please check other post in below link.

Update your wordpress site security settings

504 Gateway Time-out issue

In some server, while we doing the long execution, pages will redirect to “504 Gateway Time-out issue“.

Its due to execution time out issue.
It will 504 issue in below cases.
1. Importing SQL from server phpMyAdmin
2. Working on uploading image process.
3. Uploading large file.
4. Any process runes more then “max_execution_time

Solution:
The max_execution_time default set to 6000 seconds and the max_input time is set to 60 seconds. I would recommend
setting these higher.

We could update in below path in Plesk:
Home->Domains->domainname.com->PHP Settings->max_execution_time
Home->Domains->domainname.com->PHP Settings->max_input_time

Also, we could change max_execution_time and max_input_time through htaccess, php.ini OR PHP too.

 

Also, Some times we need to update max_children(Plesk) server.

To increase this setting, simply enter the below in the PHP settings tab > Additional configuration directives, where
X is the number you would like to increase this to. Please be aware however, that raising this too high may lead too
memory usage issues. However for the moment there is plenty of RAM available.

pm.max_children = X

 

Need to take action in below points once removed the malware code

You will want to take all of the following actions for each account/CMS to get this resolved:


-Examine the indicated files and if necessary, remove the identified files from public_html.
-Update the core CMS installation and all themes, plugins, addons, modules, templates, etc.
-Change the cPanel account password and any FTP account passwords that have access to upload.
-Change the CMS administrator password.
-Change any email account passwords with access to resetting the CMS administrator password.
-Scan any computers with access to the server with anti-virus software and Malwarebytes and Spybot Search&Destroy.

Going forward, you’ll want to make sure that you keep the CMS installations more up-to-date and please let me know if you have any questions.

SMTP mail Configuration

Please follow the below steps to configure the SMTP mailing process within your server.

  1. Click Here to Download Recent phpmailer files.
  2. Create php file with below coding.
  3. Include PHPMailer Autoload file as like below coding. (This file will change based on phpmailer  version)
    <?php
    require_once("SMTP_NEW/PHPMailerAutoload.php"); // path to the PHPMailer class
    ?>
  4.  Use the below code to implement the Mailing process.
    <?php
    $mail = new PHPMailer;//$mail->SMTPDebug = 3; // Enable verbose debug output
    $mail->isSMTP(); // Set mailer to use SMTP
    $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->Username = 'user@example.com'; // SMTP username
    $mail->Password = 'secret'; // SMTP password
    $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587; // TCP port to connect to
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
    $mail->addAddress('ellen@example.com'); // Name is optional
    $mail->addReplyTo('info@example.com', 'Information');
    $mail->addCC('cc@example.com');
    $mail->addBCC('bcc@example.com');
    $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
    $mail->isHTML(true); // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
    echo 'Message has been sent';
    }
    ?>
  5.  Follow the below STEPS to Fix the issue.While we configure it, we have tried with GMAIL SMTP as like below configuration:
    <?php
    $mail->Mailer = "smtp";
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = "ssl"; // OR $mail->SMTPSecure = 'tls';
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465;
    ?>
  6.  But, above settings displayed SMTP connection error. Then, we have tried using Port 587Then, enabled the Debug process using 
    <?php
    $mail->SMTPDebug = 1;
    ?>

     
  7.  No help, then we have discussed with server support team to confirm the OPEN PORT and SMTP Configuration details.
  8. Finally we have followed below URLs steps to fix the issue. Its related to Google URLs. Its related the enable all access permission to Google SMTP.
    https://accounts.google.com/b/0/DisplayUnlockCaptcha
    https://support.google.com/mail/answer/14257?rd=1

    Allowing less secure apps to access your account:
    https://support.google.com/accounts/answer/6010255
    https://www.google.com/settings/security/lesssecureapps (Access for less secure apps — Turn on)

Need to know below information:
1. While we configure the Gmail SMTP, it not allow to send mail “From ” another email. Like if you configured the SMTP using “xxxx@gmail.com“, sending mail default from address will be same “xxxx@gmail.com“.

If we need to change as client email, we need to create new gmail account with client name OR we need create google App with your domain OR need to configure own SMTP.
Link: https://apps.google.com/
Search keyword: Get gmail for own domain.

 

TEST THE SITE IN SHARED HOSTING BEFORE SWITCHING THE DNS RECORDS

Before Mapping the Domain and switching the DNS records, we could test the development site in shared hosting using below Options!

For Windows 7 and vista

Step 1. Open the folder C:\Windows\System32\drivers\etc

 

 

 

Step 2.  Double-click on the ‘hosts’ file and choose the Notepad from the list of available software:

host

 

notepad

 

 

Step 3.  Input the following strings in the end of the document:

Domain

Example

IP_address domainname.com
IP_address www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

Step 4. Save the changes.

Completed

 

For Windows 8 or 8.1:

Step 1. Open Notepad with Administrative privileges by clicking Start button

Step 2. Find Applications > type Notepad in search bar and then right-click Notepad and select to Run as Administrator:

Step 3. Once Notepad is opened with Administrative privileges click the File menu > choose Open:

Step 4. Browse to C:\Windows\System32\drivers\etc (you may simply copy this path to address bar and click Enter):

Step 5. Click to show All Files:

Step 6. Choose ‘hosts‘ file and click Open:

Step 7. Insert the following strings in the end of the document:

IP_address  domainname.com
IP_address  www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

Step 8. Save changes.

completed

 

For Mac OS:

STEP  1. Open the Terminal.app, either by start typing Terminal on the Spotlight, or by going into Applications >Utilities > Terminal:

STEP  2. Open the hosts by typing on the Terminal that you have just opened:
sudo nano /private/etc/hosts

STEP  3. Type your user password when prompted (you can navigate the file using the arrow keys).

STEP  4. Edit the hosts file appending your new mappings underneath the default ones:

IP_address domainname.com
IP_address www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

STEP  5. Save the hosts file (when done editing the hosts file, press CTRL+O to save the file > press Enter on the filename prompt > Ctrl+X to exit the editor).

STEP  6. Flush the DNS cache (you can issue a simple Terminal command to flush the DNS cache depending on the version of OS X you are using and have your host file changes to take immediate effect).

NOTE: After completed the testing OR Once Domain mapped to the server, you need to revert the changes back. So, you need to remove the new entries added to your host file or simply comment them by adding ‘#’ at the beginning of each line, then save the changes.

Completed