Category Archives: Server Configuration and Handling

Move WordPress Blog to New Domain/Location or in another folder/directory

You usually need to move your blog (WordPress) if you are switching your web host as we generally work on localhost.You must also need to ‘move’ your website if you are transferring it to a new domain, new folder, or creating an alternate version on a local server.

After uploading file and updating wp-config.php.We have found that there are lots of URL in the database, It is very hard to update these rows one by one with new URL.
Don’t worry. It is very simple to go

Just 4 steps to do.

1. Query to Update WordPress Settings

UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-web-url.com’, ‘http://www.new-web-url.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

2. Query to Update Permalinks

UPDATE wp_posts SET guid = replace (guid, ‘http://www.old-web-url.com’,’http://www.new-web-url.com’);

3. Query to Update Any Links Embedded In Content

UPDATE wp_posts SET post_content = replace (post_content, ‘http://www.old-web-url.com’, ‘http://www.new-web-url.com’);

4. Query to Post Metas

UPDATE wp_postmeta SET meta_value = replace (meta_value,’http://www.old-web-url.com’,’http://www.new-web-url.com’);

Sometimes, you have omitted the www from your domain when cross-linking posts or referencing images, so you should also run these above query without the ‘www’ for your old URL.

After following these steps, hope you will found your blog or website fully functional.
If it is still not functional, make a comment below this article with explanation what issue you are facing.

Set up multiple virtual hosts on XAMPP for windows

You just have to update the following files:

X:\xampp\apache\conf\extra\httpd-vhosts.conf

 

First of all,  uncomment the following line to enable name based virtual host on your server’s port 80:

NameVirtualHost *:80

 

Then you can start adding your virtual hosts. The following listing is just a sample, I usually do.I am assuming ,we create a project which should be accessible by entering http://demo-project in your browser’s address bar.

<VirtualHost *>
DocumentRoot “X:/xampp/htdocs”
ServerName localhost
</VirtualHost>

<VirtualHost *>
DocumentRoot “X:/xampp/htdocs/mywebsite/webroot”
ServerName test-project
</VirtualHost>

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot X:/xampp/htdocs/demo-project/public
ServerName demo-project

<Directory “X:/xampp/htdocs/demo-project/public”>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

 

Make sure the DocumentRoot exists and matches the Directory and remember the value you set for ServerName.

 

2. Edit your windows hosts file

Now your apache is ready,but you have to tell your system what to do if you enter http://demo-project in your browser.The most simple way to deal this is to update your hosts file you can find it from here.

C:\WINDOWS\system32\drivers\etc

(Path wil be different if windows installed else where)

 

The file is just a simple text file which contains IP-to-hostname mappings. Edit the file with a text editor and append a new line which maps the hostname you specified in apache’s ServerName-directive to 127.0.0.1. You can place it just under the existing one which defines localhost. In the end, your file could look like this:

# some comments

127.0.0.1        localhost
127.0.0.1        test-project
127.0.0.1        demo-project

 

Restart your Apache Server in order to load the new configuration and enjoy 🙂

 

How to change or reset XAMPP MySQL root password?

If you want to reset or change xampp mysql password, or have forgot the password for accessing phpMyAdmin then just follow the below step to reset the password or change the password.

 

You can do this by two methods.

 

Method 1

The easiest way is to use the security console, which you can access at http://localhost/security/
This “console” creates a password for the MySQL user “root” and is adjusting the phpMyAdmin configuration.

http://localhost/security/xamppsecurity.php

 

Method 2

With the “XAMPP Shell” (command prompt) you can also reset the password. Open the shell and execute this command
mysqladmin.exe -u root password newpassword

 

Of course, your password should not be “newpassword”, too. In the next step you must adjust the phpMyAdmin configuration for this new password. In the file “D:\xampp\phpMyAdmin\config.inc.php” change the lines:

[php]
$cfg[‘Servers’][$i][‘user’] = ‘root’;
$cfg[‘Servers’][$i][‘password’] = ”;
[/php]

To:

[php]
$cfg[‘Servers’][$i][‘user’] = ‘root’;
$cfg[‘Servers’][$i][‘password’] = ‘newpassword’;
[/php]

 

Instead in the XAMPP Shell, you can also change the password with phpMyAdmin, and then adjust the phpMyAdmin configuration.

I hope, it will help.

Use of Environment variables

Environment variables windows

 

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.

 

You can say, It is a dynamic “object” that stores a value, which in turn can be referenced by one or more software programs in Windows (OS). Environment variables help programs know what directory to install files in, where to store temporary files, where to find user profile settings, and many other things.

 

Variable names are NOT case sensitive in Windows OS.

 

Environment variables are dynamic because they can change. The values stored can be changed to match the current system’s setup and design (environment). They can also differ between computer systems because each computer can have a different setup.

 

There are a number of environment variables that get referenced by programs and can come in handy for a computer user to find needed information about their computer environment.

Below is the list of some common and important environment variables.

 

%appdata%
%commonprogramfiles%
%local%
%localappdata%
%programfiles%
%temp%
%userprofile%
%windir%

 

You can get some common information using environment variable quickly.

 

You can quickly access any of the above folders by entering the environment variable in the Windows Run box or Windows Search Box.
e.g: To get into the Application Data folder type %appdata% and then press Enter in the Run box.

 

%appdata%
The %appdata% environment variable contains the directory path to the Application Data folder for your user profile. This folder stores settings and logs, among other things, for various software programs. The settings and logs stored there are specific to your user profile.

 

%commonprogramfiles%
The %commonprogramfiles% environment variable contains the directory path to the Common Files folder, within the main Program Files folder. This folder contains various files for common programs and utilities on a computer, mostly system and services related. The default directory path this variable points to is c:\Program Files\Common Files.

 

%local%
The %local% environment variable points to where the security policies & rules are located for the user’s account, Windows in general, Windows Firewall, Network, and various software programs on the computer. This environment variable is native to Windows 7.

 

%localappdata%
The %localappdata% environment variable contains the directory path to where programs store their temporary files. Common temporary files to be stored here are Desktop Themes, Windows Error Reporting, program caching and Internet browser profiles. This environment variable is native to Windows Vista & Windows 7.

 

%programfiles%
The %programfiles% environment variable contains the directory path to where programs are installed. This directory contains sub-directories for each program, which contain the primary files needed by each program in order to run on a computer. The default directory path this variable points to is c:\Program Files.

 

%temp%
The %temp% environment variable contains the directory path to where temporary files stored. These temp files are often Internet temporary files and other user application temporary files (Microsoft Word, Excel, Outlook, etc.).

 

%userprofile%
The %userprofile% environment variable points to the current logged in user’s profile and the directory where user profile data is stored. It is in this directory that a user can find the following folders: My Documents, My Music, My Pictures, Desktop, and Favorites (Internet Explorer bookmarks).

 

%windir%
The %windir% environment variable points to the Windows directory, where Windows system files are located.The default directory path for most versions of Windows is c:\Windows (for Windows NT 4 and 2000, it is c:\WinNT).

 

Deprecated features in PHP 5.3.x or later

PHP 5.3.0 introduces two new error levels named as E_DEPRECATED and E_USER_DEPRECATED.

 

The E_DEPRECATED error level is used to indicate that a function or feature has been deprecated.

 

The E_USER_DEPRECATED level is intended for indicating deprecated features in user code, similarly to the E_USER_ERROR and E_USER_WARNING levels.

 

The following is a list of deprecated INI directives.
Use of any of these INI directives will cause an E_DEPRECATED.

define_syslog_variables
register_globals
register_long_arrays
safe_mode
magic_quotes_gpc
magic_quotes_runtime
magic_quotes_sybase
Comments starting with ‘#’ are now deprecated in .INI files.

 

Deprecated functions:

[php]
1.call_user_method()
Can be used call_user_func() instead

2.call_user_method_array()
Can be used call_user_func_array() instead

3.define_syslog_variables()
dl()

4.ereg()
Can be used preg_match() instead

5.ereg_replace()
Can be used preg_replace() instead

6.eregi()
Can be used preg_match() with the ‘i’ modifier instead

7.eregi_replace()
Can be used preg_replace() with the ‘i’ modifier instead

8.set_magic_quotes_runtime() and its alias, magic_quotes_runtime()

9.session_register()
Can be used the $_SESSION superglobal instead

10.session_unregister()
Can be used the $_SESSION superglobal instead

11.session_is_registered()
Can be used the $_SESSION superglobal instead

12.set_socket_blocking()
Can be used stream_set_blocking() instead

13.split()
Can be used preg_split() instead

14.spliti()
Can be used preg_split() with the ‘i’ modifier instead

15.sql_regcase()

16.mysql_db_query()
Can be used mysql_select_db() and mysql_query() instead

17.mysql_escape_string()
Can be used mysql_real_escape_string() instead

18.Passing locale category names as strings is now deprecated. Use the LC_* family of constants instead.
The is_dst parameter to mktime(). Use the new timezone handling functions instead.
[/php]

 

Deprecated features:

       * Assigning the return value of new by reference is now deprecated.

       * Call-time pass-by-reference is now deprecated.

 

Deprecated variables:

HTTP_ENV_VARS  use $_ENV instead
HTTP_GET_VARS  use $_GET instead
HTTP_POST_VARS  use $_POST instead
HTTP_POST_FILES  use $_FILE instead
HTTP_COOKIE_VARS  use $_COOKIE instead
HTTP_SESSION_VARS  use $_SESSION instead

 

You should take care the above in the coding, so that the code will run new in versions of PHP also.

If you have some more in this list, Please share with scriptarticle.com with comments.

 

Automatically set permission to various file types using .htaccess

Set file permissions with .htaccess, this is a great method for ensuring the CHMOD settings for various file types.

 

Apply the following rules in the root .htaccess file to affect all specified file types, or place in a specific directory to affect only those files (add/update file types according to your needs)

[sourcecode language=”plain”]
# ensure CHMOD settings for specified file types
# never set CHMOD 777 unless you know what you are doing?
# files requiring write access should use CHMOD 766 rather than 777
# keep specific file types private by setting their CHMOD to 400

chmod .htpasswd files 640
chmod .htaccess files 644
chmod php files 600
[/sourcecode]

 

Require SSL (Secure Sockets Layer)

Here is an easy way you can go using .htaccess file

[sourcecode language=”plain”]
# require SSL without mod_ssl
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
[/sourcecode]

 

Guys, If you still face any issue regarding this, leave a comment in the comment box.