Can I help? https://lemuel.leung.us Lemuel Leung | Hosting Consultant Mon, 20 Jul 2020 08:26:33 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://lemuel.leung.us/wp-content/uploads/2019/06/cropped-lemico-32x32.png Can I help? https://lemuel.leung.us 32 32 Cloudflare and WordPress multisite https://lemuel.leung.us/cloudflare-and-wordpress-multisite/ https://lemuel.leung.us/cloudflare-and-wordpress-multisite/#respond Tue, 18 Feb 2020 17:29:10 +0000 https://lemuel.leung.us/?p=554 Read more about Cloudflare and WordPress multisite[…]]]> Issue: Site uses Cloudflare and uses flexible SSL to serve pages. However, within WordPress, any http:// referenced sources are being referenced as http:// instead of https://

Solution 1: For the site in question, you can force resources to automatically upgrade. Put the following line in your .htaccess file:

Header always set Content-Security-Policy: upgrade-insecure-requests

An explanation of what that does is listed here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests

Solution 2: Insert this script below your functions.php file in your child theme and they should load again (but note, updating the theme might break this and you will need to do it again):

 function ssl_srcset( $sources ) {
 foreach ( $sources as &$source ) {
 $source['url'] = set_url_scheme( $source['url'], 'https' );
 } 
 return $sources;
 }
 add_filter( 'wp_calculate_image_srcset', 'ssl_srcset' );

Credit:
http://docs.layerswp.com/doc/wordpress-images-dont-load-after-4-4-update-with-ssl-enabled/

]]>
https://lemuel.leung.us/cloudflare-and-wordpress-multisite/feed/ 0
WordPress/MySQL change URLs https://lemuel.leung.us/wordpress-mysql-change-urls/ https://lemuel.leung.us/wordpress-mysql-change-urls/#respond Tue, 18 Feb 2020 17:22:20 +0000 https://lemuel.leung.us/?p=552 ; SHOW TABLES; Grab site URLs SELECT * FROM wp_options WHERE option_name = 'home'; SELECT * FROM wp_options WHERE option_name = 'siteurl'; **NOTE** Multisite setups are different. Each site has their own set of wp_options, depending on your site, it may be set Read more about WordPress/MySQL change URLs[…]]]> Connect to MySQL and view tables to see what you need

USE <DB_NAME>;
SHOW TABLES;

Grab site URLs

SELECT * FROM wp_options WHERE option_name = 'home';
SELECT * FROM wp_options WHERE option_name = 'siteurl';

**NOTE** Multisite setups are different.  Each site has their own set of wp_options, depending on your site, it may be set to different numbers.  Typically, it will be wp_2_options, wp_3_options, etc.

Replace values with what you want

UPDATE wp_options SET option_value="http://new_host/wordpress" WHERE option_name = "home";
UPDATE wp_options SET option_value="http://new_host/wordpress" WHERE option_name = "siteurl";

**NOTE** For multisite setups, make sure your wp_options match the number for the site in question.  
]]>
https://lemuel.leung.us/wordpress-mysql-change-urls/feed/ 0
Malware/Hack on website, what to check? https://lemuel.leung.us/malware-hack-on-website-what-to-check/ https://lemuel.leung.us/malware-hack-on-website-what-to-check/#respond Thu, 13 Feb 2020 17:59:11 +0000 https://lemuel.leung.us/?p=548 Read more about Malware/Hack on website, what to check?[…]]]> Issue: Site hacked, payload dropped, compromised. How, where to go, and what to do.

FIRST: Resolve and remove the offending content
– Restore your website from good backups
– Double-check your files, if it’s a CMS (like WordPress), try to restore from the original install files and ONLY bring in necessary files (ie. wp-content/themes/plugins folders, etc.)
– scan file/folders for any affected malware/viruses
– search for eval and base64 code that shouldn’t belong

SECOND: Search online for site blacklisting and use online scanners to verify your findings
– https://www.dnsblacklist.org/ – blacklisting
– https://quttera.com/ – online scanner

THIRD: Line up for a battle to remove yourself from these blacklists
– It might be in your best interest to go after the larger providers
1. Google, you have to prove you own the domain, then submit a removal request. You may need to submit a few requests to be removed.
2. OpenDNS – open a ticket with their support team and wait for their response.

FOURTH: Now that you have time, review your files, logs (FTP, web, etc.)
– Determine the cause and entry point for the site infraction
– secure entry points and test to make sure they are secured

]]>
https://lemuel.leung.us/malware-hack-on-website-what-to-check/feed/ 0
WordPress can’t connect to database after MySQL move to new datadir https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/ https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/#respond Mon, 09 Dec 2019 09:48:14 +0000 https://lemuel.leung.us/?p=536 Read more about WordPress can’t connect to database after MySQL move to new datadir[…]]]> Resolution:
The problem is related to your moving the mysql.sock file to a new location. PHP needs to know where it is, changing the location will fix the problem and reload apache/httpd (if you are using php-fpm, restart the service)

Easy fix: Edit your php.ini file and make sure you specify the new mysql.sock location.

mysqli.default_socket = /path/to/your/files/mysql.sock

Issue: After moving your datadir for MySQL, WordPress will still not pull up and present the “Error connecting to the database” error.

RELATED ARTICLE(S):

1. Moving mysql datadir in Redhat (don’t forget SELinux!)
2. WordPress troubleshooting

]]>
https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/feed/ 0
Moving mysql datadir in Redhat (don’t forget SELinux!) https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/ https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/#respond Mon, 09 Dec 2019 09:37:50 +0000 https://lemuel.leung.us/?p=533 Read more about Moving mysql datadir in Redhat (don’t forget SELinux!)[…]]]> Issue: You have moved /var/lib/mysql data files to their new destinations, but mysql will not start up.

Resolution(s):

1. Review and verify configurations

       (in this example, MySQL 8)
- /etc/my.cnf.d/mysql-server.cnf
datadir=/ & socket=/ set to the right folder?
- /etc/my.cnf.d/client.cnf
add the following lines under [client]:
datadir=/path/to/your/files
port=3306

2. Grant SELinux permissions to the new folder

Run the following commands to change the datadir
#semanage fcontext -a -t mysqld_db_t "/path/to/your/files(/.*)?"
# restorecon -Rv /path/to/your/files

Run the following commands to change the mysql.sock file
# semanage fcontext -a -t mysqld_var_run_t "/path/to/your/files/mysql.sock"
# restorecon -Rv /path/to/your/files/mysql.sock 

RELATED ARTICLES(S)

After moving the above and restarting MySQL successfully, WordPress still would not load.

See the following article for help with troubleshooting WordPress: click here
See the following article for making sure PHP is configured correctly: click here

]]>
https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/feed/ 0
Connection errors from WordPress to Azure MySQL database https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/ https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/#respond Thu, 31 Oct 2019 06:35:23 +0000 https://lemuel.leung.us/?p=504 Read more about Connection errors from WordPress to Azure MySQL database[…]]]> Issue: You are getting connection issues to your hosted Azure MySQL database server. You are putting the correct information in, but still WordPress is showing Error Connecting to Database.

Error: After some investigation, you most likely are getting this error:

mysqli_real_connect(): (HY000/9002): SSL connection is required. Please specify SSL options and retry

Resolution: Believe it or not, this is a simple one. Azure REQUIRES that your connection to the database uses SSL.

Simply put the following line in your wp-config.php file and all will be well. I typically include a description for my own reference

/** Secure Connection to Azure MySQL db */
define(‘MYSQL_CLIENT_FLAGS’, MYSQLI_CLIENT_SSL);

]]>
https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/feed/ 0
WordPress troubleshooting https://lemuel.leung.us/wordpress-troubleshooting/ https://lemuel.leung.us/wordpress-troubleshooting/#respond Sat, 29 Jun 2019 05:58:41 +0000 https://lemuel.leung.us/?p=487 Read more about WordPress troubleshooting[…]]]> Issue: You are having trouble with your WordPress installation and can’t figure out exactly the issue. It may be that you are on a server and have limited visibility.

Resolution: Save the following four lines, these are a MUST for those who are moving sites across platforms or to another host.

ADD THE FOLLOWING TO YOUR WP-CONFIG.PHP FILE

define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
ini_set(‘display_errors’, 0);

Once these settings are turned on, you will be able to navigate to your root folder, wp-content folder, and a new file will pop up: debug.log

Troubleshoot away! Your debug.log file will contain all that you need to figure out the issue.
]]>
https://lemuel.leung.us/wordpress-troubleshooting/feed/ 0
Rewrite rule – Force HTTPS / Linux https://lemuel.leung.us/rewrite-rule-force-https-linux/ https://lemuel.leung.us/rewrite-rule-force-https-linux/#respond Tue, 27 Nov 2018 20:48:10 +0000 https://lemuel.leung.us/?p=436 Read more about Rewrite rule – Force HTTPS / Linux[…]]]> Forcing HTTPS is very easy to do in Apache.

The common command is to force everything to HTTPS. In your host file, under :80 make sure you have the following. At the same time, make sure you have :443 open and that your configuration is ready to host the new traffic.

#Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

To check if your apache config is working properly, you can run: apachectl configtest

]]>
https://lemuel.leung.us/rewrite-rule-force-https-linux/feed/ 0
Script for Chrome cache multiple users https://lemuel.leung.us/script-for-chrome-cache-multiple-users/ https://lemuel.leung.us/script-for-chrome-cache-multiple-users/#respond Mon, 28 Aug 2017 03:08:17 +0000 https://lemuel.leung.us/?p=385 Read more about Script for Chrome cache multiple users[…]]]> I found a script this very useful script. It does a good job of cleaning the Chrome cache in user profiles on a terminal server.

Original Post: https://community.spiceworks.com/topic/1425012-clear-chrome-cache-for-multiple-users-on-file-server

Thanks!

========

@ECHO On

TASKKILL /F /IM Chrome.exe /T

for /f %%a in (‘dir c:\users /b’) do (

rd “c:\users\%%a\AppData\Local\Google\Chrome\User Data\Default\Cache” /s /q

del “c:\users\%%a\AppData\Local\Google\Chrome\User Data\Default\*history*.*” /s /q

del “c:\users\%%a\AppData\Local\Google\Chrome\User Data\Default\*History Provider Cache*.*” /s /q

del “c:\users\%%a\AppData\Local\Google\Chrome\User Data\Default\*cookies*.*” /s /q

)

exit /b 0

]]>
https://lemuel.leung.us/script-for-chrome-cache-multiple-users/feed/ 0
Script for disk cleanup https://lemuel.leung.us/script-for-disk-cleanup/ https://lemuel.leung.us/script-for-disk-cleanup/#respond Mon, 13 Mar 2017 08:21:36 +0000 https://lemuel.leung.us/?p=330 Read more about Script for disk cleanup[…]]]> @echo off
REM Install Disk Cleanup based on Windows Version

ver | findstr /i “6\.0\.” > nul
IF %ERRORLEVEL% EQU 0 goto ver_2008
ver | findstr /i “6\.1\.” > nul
IF %ERRORLEVEL% EQU 0 goto ver_2008R2
goto warn_and_exit

:ver_2008
:Run Windows 2008 specific commands here
echo OS Version: Windows 2008
IF NOT EXIST “%SYSTEMDRIVE%\Program Files (x86)” goto ver_2008_x86
echo 64-bit

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui C:\Windows\System32\en-US\
cleanmgr.exe

goto end

:ver_2008_x86
echo 32-bit

copy C:\Windows\winsxs\x86_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_6d4436615d8bd133\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\x86_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_5dd66fed98a6c5bc\cleanmgr.exe.mui C:\Windows\System32\en-US\
cleanmgr.exe

goto end
:ver_2008R2
:Run Windows 2008R2 specific commands here
echo OS Version: Windows 2008 R2

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\
cleanmgr.exe

goto end

:warn_and_exit
echo Machine OS cannot be determined.

:end

]]>
https://lemuel.leung.us/script-for-disk-cleanup/feed/ 0