How to keep SSH connections alive putty

How to keep SSH connections alive putty

KEEPING SSH CONNECTIONS ALIVE

Depending on your hardware and software configuration, you may experience SSH connectivity issues. For example, some types of firewalls may preemptively close connections after a certain amount of time has elapsed.

To work around these types of problems, you can adjust your SSH client’s settings. Follow the appropriate procedure below for your own operating system.

Windows operating systems

Microsoft Windows operating systems use the PuTTY program to establish SSH connections. If you experience connectivity issues, you can adjust PuTTY’s configuration to help keep connections alive. To do this, follow these steps:

  1. Start PuTTY.
  2. Load your connection session.
  3. In the Category pane, click Connection.
  4. Under Sending of null packets to keep session active, in the Seconds between keepalives, type 240.
    With this configuration, PuTTY sends a packet to the server every 240 seconds (4 minutes) to keep the connection alive.
  5. In the Category pane, click Session.
  6. Click Save.
  7. Connect to your account and monitor the connection. If it stil drops, gradually decrease the keepalive interval until the connection is stable.
Linux and Mac OS X operating systems

On Linux and Apple Mac OS X operating systems, the ~/.ssh/config file enables you to specify many SSH settings, including those that keep alive an SSH connection. To do this, follow these steps:

  1. Use your preferred text editor to open the ~/.ssh/config file on your local computer.
    If the .ssh directory or the config file do not exist, create them.
  2. Add the following lines to the config file. The Host value can be any name you want; it is simply a label for the other settings. The Hostname value is the remote host you want to access; replace example.com with your domain name. Replace usernamewith your own A2 Hosting account username:
    Host example
        Hostname example.com
        Port 7822
        User username
        ServerAliveInterval 240
        ServerAliveCountMax 2


    • With this configuration, the SSH client sends a packet to the server every 240 seconds (4 minutes) to keep the connection alive. If the client does not receive a response after two tries (as specified by the ServerAliveCountMax setting), it closes the connection.
    • For detailed information about all of the SSH configuration settings available, type man ssh_config at the command line.
  3. Save the changes to the config file.
  4. Connect to your account using SSH. To do this, simply type ssh example where example represents the Host value you specified in step 2.
  5. Monitor the connection. If it still drops, gradually decrease the ServerAliveIntervalsetting in the config file until the connection is stable.

Default .htaccess file for WordPress?

Default .htaccess file for WordPress?

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress



How to host a Node.Js application in shared hosting

How to host a Node.Js application in shared hosting

In short you first install NVM, then you install the Node version of your choice with NVM.

wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash

Your restart your shell (close and reopen your sessions). Then you

nvm install stable

to install the latest stable version for example. You can install any version of your choice. Check node --version for the node version you are currently using and nvm list to see what you’ve installed.

In bonus you can switch version very easily (nvm use <version>)

What’s the version of my OS?

 

 

What’s my OS?

 
What’s an OS?
OS is an abbreviation for the word Operating System. An Operating System is the software that tells a computer how to operate. It controls hardware, executes programs, manages tasks and resources, and provides the user with an interface to the computer.
What’s the version of my OS?
Windows

 

  • Windows 10 or Windows Server 2016 – Go to Start, enter About your PC, and then select About your PC. Look under PC for Edition to find out your version and edition of Windows.
  • Windows 8.1 or Windows Server 2012 R2 – Swipe in from the right edge of the screen, tap Settings, and then tap Change PC settings. (If you’re using a mouse, point to the lower-right corner of the screen, move the mouse pointer up, click Settings, and then click Change PC settings.). Next, Tap or click PC and devices, and then tap or click PC info. Look under Windows for the version and edition.
  • Windows 8 or Windows Server 2012 – On the Start screen, type Computer, press and hold or right-click Computer, and then tap or click Properties. Then look under Windows edition for the version.
  • Windows 7 and Windows Server 2008 R2 – Click Start or the Windows logo right click Computer then click Properties. Look in System.
  • Windows Vista and Windows Server 2008 – Click Start or the Windows logo depending on what you have then click Control Panel->System and Maintenance->System.You could also try Clicking Start or the Windows logo then if you have a “Start Seach” field type winver then Double-click winver.exe from the results. If you had a run box instead of search just click Run type winver click OK.
  • Windows NT, Windows 2000, Windows XP and Windows Server 2003 – Click Start -> RunType winver then click OK. You could also try typing msinfo32 or sysdm.cpl or winmsd if you like. Lastly you might try typing dxdiag. Windows might prompt you to verify drivers click No.
  • Windows 95/98/ME – Click Start-> Settings->Control Panel double-click System click General tab. Locate version number under system heading. Click here for chart to match version number to release.
  • Windows CE – Click StartSettings Control Panelclick the System applet. If that does not work you might just have to look in the General Tab or somewhere in the System Tab.You can also find out if your computer is running a 32-bit or 64-bit version of Windows in the same areas listed above.

Macintosh

  • OS X (Mac OS X) – Click the Apple menu at the top of your screen then click About this Mac. To get more detailed information after that click More Info -> Software. Note: Apple has changed the name of it’s OS to OS X from Mac OS X.
  • iOS (iPhoneOS) – On your iPhone touch Settings -> General -> About. Look under version. Note: Apple has changed the name of it’s OS to iOS from iPhoneOS.

Linux

  • Open a terminal program (get to a command prompt) and type uname -a. This will give you your kernel version, but might not mention the distribution your running. To find out what distribution of linux your running (Ex. Ubuntu) try lsb_release -a or cat /etc/*release or cat /etc/issue* or cat /proc/version.

FreeBSD/NetBSD/OpenBSD/DragonFlyBSD

  • Open a terminal program (get to a command prompt) and type uname -a. This will tell you the version (release) and type of BSD your running.

Android Phone




  • Go to the Home Screen (push the home button or just keep pressing the left facing triangle (back button)). Then push the Applications button (looks like little squares or like 3 colons :::). Find and touch the Settings icon. Scroll to the bottom of the list. then touch About Phone. Look for lines that say Firmware version or Android version.

Blackberry (RIM OS)

  • Go to the Options menu and choose About. If that does not work try the Tools icon then click on Settings then About.

Solaris (SunOS)

  • Open a terminal program (get to a command prompt) and type uname -a or for lots of info (on newer Solaris machines) type showrev -a.

AIX

  • Open a terminal program (get to a command prompt) and type oslevel -r or uname -a or lslpp -h bos.rte.

IOS (Cisco)

  • On the command line in enabled mode (enable) type show version.

XOS (Extreme Networks)

  • On the command line at an administrator privilege level type show version.

IronWare OS (Foundry)

  • On the command line at an administrator privilege level type show version. For more Foundry commands look here.
Do I have a 32-bit or 64-bit OS?
Windows

 

  • Follow the instructions above in the What’s the version of my OS? section to find out if your OS is 32-bit or 64-bit. The page with the version info usually has something that says if it is 32-bit or 64-bit. Only Windows XP and later could possibly be 64-bit. If you don’t see something that says “64-bit” somewhere on the version page, it is likely you have a 32-bit version of Windows. Also, more info here or here.

Macintosh

  • Mac OS X – Click About this Mac from the Apple menu at the top of your screen. Then click More Info -> Software.Mac OS X 10.5 (or greater) can run 64-bit applications. Any processor that says: Intel Core 2 Duo, Intel Xeon, or PowerPC G5 are 64-bit processors. All currently shipping Macs ship with OS X and a 64-bit processor. 10.6 still boots a 32-bit kernel by default. It’s possible to boot at 64-bit kernel. Read all about it here.

Linux

  • Open a command prompt and type uname -a. If you see x86_64 or ia64 then your OS is 64-bit. If you see i386 or i486 or i586 or i686 then your OS is 32-bit.

OpenBSD/FreeBSD/NetBSD

  • Open a command prompt and type uname -a. If you see amd64 then you are running a 64-bit OS. If you see i386 your running a 32-bit OS.

Solaris (SunOS)

  • Open a command prompt and type isainfo -v. This will show you if your OS is capable of running 32-bit and 64-bit applications. If that does not work you can try typing uname -a. This will show you the version of Solaris your using. All versions after 5.7 are 64-bit compliant.Sun’s platforms transitioned to 64-bit over a period of time, which makes identifying the platform for 64-bit compliance tricky.

AIX

  • Open a command prompt and type getconf -a | grep KERN. If that does not work try bootinfo -K. Also, try looking at some libraries by typing file /usr/lib/boot/unix*. If you see mention of 64-bit then the OS is 64-bit capable.
How do you know what my OS is?
Black magic. Just kidding. When you visit a site with your web browser it sends a little nugget of information to that site called a “User Agent”. The user agent has a few minor pieces of information about your browser, platform, and OS version. Using this information a guess can be made about what Operating System your using.

 

Why is it a guess? The user agent your browser sends to the website can be changed very easily. It’s not to be trusted in any way, shape, or form as the truth, but most people generally use browsers who’s user agents have not been changed.

Why is it only generally? Sometimes the people that provide your internet access will modify this user agent so the website can not tell what your browser is or will set the user agent to a general browser type so the site will render the same for everyone. This is not the norm so don’t fret to much.

Why does the site not display my OS version or displays the wrong version?
Most browsers do not put the version number of the OS in the user agent string but some do. Apple products are a good example. The browsers that put OS version information in the user agent string are usually the browsers come with the OS or are created (compiled) by the vendor. The vendors built-in browser will provide the most information to this site for it to render the most accurate guess. For example Apple’s built-in browser Safari provides the full version of the OS in the user agent string, but Firefox on the same Apple computer only provdes a portion of the version number.
Why does it say my OS is “Unknown”?
First, read the section called “How do you know what my OS is?”. Now that you know how we go about guessing your OS you might have an idea on why we can’t. The most likely answer is that there might not be enough information in your user agent string to render a good guess or since the user agent is so easily changed yours could have been changed to something that is not normal or is so obscure that a guess could not even be rendered. It’s a good chance it’s nothing you did so don’t worry. Go through the “What’s the version of my OS” section above and see if you notice anything mentioned there. It’s likely you have an idea what OS your using your just not sure.
Why did the site guess my OS incorrectly?
Guessing an Operating System by just using a user agent is not as easy as it looks. There are so many little differences between each one. Words are not always in the same spot. Some things are spelled differently. The list goes on and on. This site is constantly being monitored, updated, and tweaked to fix errors. If it got your OS incorrect one day come back later and it might be correct in the future. If your OS was guessed incorrectly submit your user agent and your correct os to os at whatsmyos.com. It will be looked into and if possible fixed.
What is up with the “or possibly Windows Server…” in some of the windows lines?
Microsoft decided that they would share OS version numbers between desktop and server releases of their Operating Systems. That means the server and desktop user agents look almost exactly the same. It is possible that you are using a server version of Windows, but very unlikely if you are just a regular home user. Usually if your running Windows server you know it. Use the ways above to help you verify your Windows version.
What does my user agent look like?
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36



25 PHP Interview Questions and Answers You Should Know

25 PHP Interview Questions and Answers You Should Know

PHP Interview Question #1

What’s the difference between the include() and require()functions?

They both include a specific file but on require the process exits with a fatal error if the file can’t be included, while include statement may still pass and jump to the next step in the execution.

PHP Interview Question #2

How can we get the IP address of the client?

This question might show you how playful and creative the candidate is because there are many options. $_SERVER["REMOTE_ADDR"]; is the easiest solution, but the candidate can write x line scripts for this question.

PHP Interview Question #3

What’s the difference between unset() and unlink()

unset() sets a variable to “undefined” while unlink() deletes a file we pass to it from the file system.

PHP Interview Question #4

What is the output of the following code:

$a = '1';
$b = &$a;
$b = "2$b";
echo $a.", ".$b;

PHP Interview Question #5

What are the main error types in PHP and how do they differ?

In PHP there are three main type of errors:

  • Notices – Simple, non-critical errors that are occurred during the script execution. An example of a Notice would be accessing an undefined variable.
  • Warnings – more important errors than Notices, however the scripts continue the execution. An example would be include() a file that does not exist.
  • Fatal – this type of error causes a termination of the script execution when it occurs. An example of a Fatal error would be accessing a property of a non-existent object or require() a non-existent file.

Understanding the error types is very important as they help developers understand what is going on during the development, and what to look out for during debugging.

PHP Interview Question #6

What is the difference between GET and POST?

  • GET displays the submitted data as part of the URL, during POST this information is not shown as it’s encoded in the request.
  • GET can handle a maximum of 2048 characters, POST has no such restrictions.
  • GET allows only ASCII data, POST has no restrictions, binary data are also allowed.
  • Normally GET is used to retrieve data while POST to insert and update.

Understanding the fundamentals of the HTTP protocol is very important to have for a PHP developer, and the differences between GET and POST are an essential part of it.

PHP Interview Question #7

How can you enable error reporting in PHP?

Check if “display_errors” is equal “on” in the php.ini or declare “ini_set('display_errors', 1)” in your script.
Then, include “error_reporting(E_ALL)” in your code to display all types of error messages during the script execution.

Enabling error messages is very important especially during the debugging process as one can instantly get the exact line that is producing the error and can see also if the script in general is behaving correctly.

PHP Interview Question #8

What are Traits?

Traits are a mechanism that allows you to create reusable code in languages like PHP where multiple inheritance is not supported. A Trait cannot be instantiated on its own.

It’s important that a developer knows the powerful features of the language (s)he is working on, and Trait is one of such features.

PHP Interview Question #9

Can the value of a constant change during the script’s execution?

No, the value of a constant cannot be changed once it’s declared during the PHP execution.

PHP Interview Question #10

Can you extend a Final defined class?

No, you cannot extend a Final defined class. A Final class or method declaration prevents child class or method overriding.

PHP Interview Question #11

What are the __construct() and __destruct() methods in a PHP class?

All objects in PHP have Constructor and Destructor methods built-in. The Constructor method is called immediately after a new instance of the class is being created, and it’s used to initialize class properties. The Destructor method takes no parameters.

Understanding these two in PHP means that the candidate knows the very basics of OOP in PHP.

PHP Interview Question #12

How we can get the number of elements in an array?

The count() function is used to return the number of elements in an array.

Understanding of arrays and array related helper functions is important for any PHP developer.

PHP Interview Question #13

How would you declare a function that receives one parameter name hello?
If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.

<?php
function showMessage($hello=false){
  echo ($hello)?'hello':'bye';
}
?>

In this question, you can evaluate if the developer knows how to declare a function and how they would manage the fact of the parameter can or cannot be on the function call. You can also evaluate if the developer knows the if syntax and how to print text(echo function).

PHP Interview Question #14

The value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?

<?php
echo array_sum(explode(',',$input));
?>

The explode function is one of the most used functions in PHP, so it’s important to know if the developer knows this function. There is no unique answer to this question, but the answer must be similar to this one.

PHP Interview Question #15

Suppose you receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would you validate whether the field is empty? Print a message "The email cannot be empty" in this case.

<?php
if(empty($_POST['email'])){
  echo "The email cannot be empty";
}
?>

In this question, the candidate should be evaluated on his/her knowledge about forms management and validation. There is not unique answer for this question, but it must be similar to this one.

PHP Interview Question #15

Suppose that you have to implement a class named Dragonball. This class must have an attribute named ballCount (which starts from 0) and a method iFoundaBall. When iFoundaBall is called, ballCount is increased by one. If the value of ballCount is equal to seven, then the message You can ask your wish is printed, and ballCount is reset to 0. How would you implement this class?

<?php
class dragonBall{
  private $ballCount;

  public function __construct(){
    $this->ballCount=0;
  }

  public function iFoundaBall(){
    $this->ballCount++;
    if($this->ballCount===7){
      echo "You can ask for your wish.";
      $this->ballCount=0;
    }
  }
}
?>

This question will evaluate a candidate’s knowledge about OOP.

PHP Interview Question #16

What are the 3 scope levels available in PHP and how would you define them?

Private – Visible only in its own class
Public – Visible to any other code accessing the class
Protected – Visible only to classes parent(s) and classes that extend the current class

This is important for any PHP developer to know because it shows an understanding that building applications is more than just being able to write code. One must also have an understanding about privileges and accessibility of that code. There are times protected variables or methods are extremely important, and an understanding of scope is needed to protect the integrity of the data in your application along with provide a clear path through the code.

PHP Interview Question #17

What are getters and setters and why are they important?

Getters and setters are methods used to declare or obtain the values of variables, usually private ones. They are important because it allows for a central location that is able to handle data prior to declaring it or returning it to the developer. Within a getter or setter one is able to consistently handle data that will eventually be passed into a variable or additional functions. An example of this would be a user’s name. If a setter is not being used and the developer is just declaring the $userName variable by hand, you could end up with results as such: "kevin""KEVIN""KeViN""", etc. With a setter, the developer can not only adjust the value, for example, ucfirst($userName), but can also handle situations where the data is not valid such as the example where "" is passed. The same applies to a getter – when the data is being returned, it can be modifyed the results to include strtoupper($userName) for proper formatting further up the chain.

This is important for any developer who is looking to enter a team-based / application development job to know. Getters and setters are often used when dealing with objects, especially ones that will end up in a database or other storage medium. Because PHP is commonly used to build web applications, developers will run across getters and setters in more advanced environments. They are extremely powerful yet not talked about very much. It is impressive if a developer shows that he/she knows what they are and how to use them early on.

PHP Interview Question #18

What does MVC stand for and what does each component do?

MVC stands for Model View Controller.
The controller handles data passed to it by the view and also passes data to the view. It’s responsible for interpretation of the data sent by the view and dispersing that data to the appropriate models awaiting results to pass back to the view. Very little, if any business logic should be occurring in the controller.

The model’s job is to handle specific tasks related to a specific area of the application or functionality. Models will communicate directly with your database or other storage system and will handle business logic related to the results.

The view is passed data by the controller and is displayed to the user.

Overall, this question is worth knowing as the MVC design pattern has been used a lot in the last few years and is a very good design pattern to know. Even with more advanced flows that go down to repositories and entities, they still are following the same basic idea for the Controller and View. The Model is typically just split out into multiple components to handle specific tasks related to database data, business logic etc. The MVC design pattern helps draw a better understanding of what is being used, as a whole, in the industry.


PHP Interview Question #19

How does one prevent the following Warning ‘Warning: Cannot modify header information – headers already sent’ and why does it occur in the first place?

The candidate should not output anything to the browser before using code that modifies the HTTP headers. Once the developer calls echoor any other code that clears the buffer, the developer can no longer set cookies or headers. That is also true for error messages, so if an error happens before using the header command and the INI directive display_errors is set, then that will also cause that error to show.

PHP Interview Question #20

What are SQL Injections, how do you prevent them and what are the best practices?

SQL injections are a method to alter a query in a SQL statement send to the database server. That modified query then might leak information like username/password combinations and can help the intruder to further compromise the server.

To prevent SQL injections, one should always check & escape all user input. In PHP, this is easily forgotten due to the easy access to $_GET & $_POST, and is often forgotten by inexperienced developers. But there are also many other ways that users can manipulate variables used in a SQL query through cookies or even uploaded files (filenames). The only real protection is to use prepared statements everywhere consistently.

Do not use any of the mysql_* functions which have been deprecated since PHP 5.5 ,but rather use PDO, as it allows you to use other servers than MySQL out of the box. mysqli_* are still an option, but there is no real reason nowadays not to use PDO, ODBC or DBA to get real abstraction. Ideally you want to use Doctrine or Propel to get rid of writing SQL queries all together and use object-relational mapping which binds rows from the database to objects in the application.

PHP Interview Question #21

What does the following code output?

$i = 016;
echo $i / 2;

The Output should be 7. The leading zero indicates an octal number in PHP, so the number evaluates to the decimal number 14 instead to decimal 16.

PHP Interview Question #22

Why would you use === instead of ==?

If you would want to check for a certain type, like an integer or boolean, the === will do that exactly like one would expect from a strongly typed language, while == would convert the data temporarily and try to match both operand’s types. The identity operator (===) also performs better as a result of not having to deal with type conversion. Especially when checking variables for true/false, one should avoid using == as this would also take into account 0/1 or other similar representation.


PHP Interview Question #23

What are PSRs? Choose 1 and briefly describe it.

PSRs are PHP Standards Recommendations that aim at standardising common aspects of PHP Development.

An example of a PSR is PSR-2, which is a coding style guide. More info on PSR-2.


PHP Interview Question #24

What PSR Standards do you follow? Why would you follow a PSR standard?

One should folow a PSR because coding standards often vary between developers and companies. This can cause issues when reviewing or fixing another developer’s code and finding a code structure that is different from yours. A PSR standard can help streamline the expectations of how the code should look, thus cutting down confusion and in some cases, syntax errors.

PHP Interview Question #25

Do you use Composer? If yes, what benefits have you found in it?

Using Composer is a tool for dependency management. The candidate can declare the libraries your product relies on and Composer will manage the installation and updating of the libraries. The benefit is a consistent way of managing the libraries depended on so less time is spent managing the libraries.

www rewrite htaccess opencart

www rewrite htaccess Opencart

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch “(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))”>
Require all denied
## For apache 2.2 and older, replace “Require all denied” with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

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

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an “Internal Server Error 500” after enabling any of the following settings, restore the # as this means your host doesn’t allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

<IfModule pagespeed_module>
ModPageSpeed on
ModPagespeedRewriteLevel CoreFilters
ModPagespeedEnableFilters prioritize_critical_css
ModPagespeedEnableFilters defer_javascript
ModPagespeedEnableFilters sprite_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>




## EXPIRES CACHING ##
<IfModule mod_expires.c>
#ExpiresActive On
#ExpiresByType image/jpg “access 1 year”
#ExpiresByType image/jpeg “access 1 year”
#ExpiresByType image/gif “access 1 year”
#ExpiresByType image/png “access 1 year”
#ExpiresByType text/css “access 1 month”
#ExpiresByType text/html “access 1 month”
#ExpiresByType application/pdf “access 1 month”
#ExpiresByType text/x-javascript “access 1 month”
#ExpiresByType application/x-shockwave-flash “access 1 month”
#ExpiresByType image/x-icon “access 1 year”
#ExpiresDefault “access 1 month”
</IfModule>

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Run Node JS Server At Background Continuously With Forever.

Run Node JS Server At Background Continuously With Forever.

You could install forever using npm like this:
# sudo npm install -g forever
And then start your application with:
# forever server.js
Or as a service:
# forever start server.js
Forever restarts your app when it crashes or stops for some reason. To restrict restarts to 5 you could use:
forever -m5 server.js
To list all running processes:
# forever list
Note the integer in the brackets and use it as following to stop a process:
# forever stop 0



Restarting a running process goes:
# forever restart 0
If you’re working on your application file, you can use the -w parameter to restart automatically whenever your server.js file changes:
# forever -w server.js



Use multiple databases in OpenCart

Use multiple databases in OpenCart

To use multiple databases in OpenCart (1.5.*), just update 3 files as given below:

  1. Config.php:
    Add:

    //New DB
    define(‘NEWDB_DRIVER’, ‘mysql’);
    define(‘NEWDB_HOSTNAME’, ‘localhost’);
    define(‘NEWDB_USERNAME’, ‘root’);
    define(‘NEWDB_PASSWORD’, ‘password’);
    define(‘NEWDB_DATABASE’, ‘sitename_newdb’);
    define(‘NEWDB_PREFIX’, ‘ndb’);

  2. Index.php:
    Below the current database setup ($db = new DB(DB_DRIVER …) add:

    $newdb = new DB(NEWDB_DRIVER, NEWDB_HOSTNAME, NEWDB_USERNAME, NEWDB_PASSWORD, NEWDB_DATABASE);
    $registry->set(‘newdb’, $newdb );

  3. system/database/mysql.php:
    Modify:

    change:
    if (!$this->link = mysql_connect($hostname, $username, $password)) {
    to:
    if (!$this->link = mysql_connect($hostname, $username, $password, true)) {




After these above steps we can access the new database by:

$this->newdb->query(“SELECT * FROM “. NEWDB_PREFIX . “users”);



multiple database connection in laravel

multiple database connection in laravel

.env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database1 //database first
DB_DATABASE_OPENCART=database2    // database second
DB_USERNAME=root
DB_PASSWORD=aaaa@#2233

config/database

‘mysql’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘localhost’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE’, ‘database1’),
‘username’ => env(‘DB_USERNAME’, ‘root’),
‘password’ => env(‘DB_PASSWORD’, ‘aaaa@#2233’),
‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’,
‘prefix’ => ”,
‘strict’ => false,
‘engine’ => null,
],
‘opencart’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘localhost’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE_OPENCART’, ‘database2’),
‘username’ => env(‘DB_USERNAME’, ‘root’),
‘password’ => env(‘DB_PASSWORD’, ‘aaaa@#2233’),
‘charset’ => ‘utf8’,
‘collation’ => ‘utf8_unicode_ci’,
‘prefix’ => ”,
‘strict’ => false,
‘engine’ => null,
],

 

In Controller file




$db_ext = DB::connection(‘opencart’);
$countries = $db_ext->table(‘fit_cart’)->get();
print_r($countries);



HOW TO DOWNGRADE WORDPRESS TO A PREVIOUS VERSION

HOW TO DOWNGRADE WORDPRESS TO A PREVIOUS VERSION

Have you ever updated to the newest version of WordPress, and then noticed that your site starts to have a bunch of problems? Don’t freak out. A lot of the times, it’s an issue with a plugin or theme that’s not compatible with the newest update. Sometimes (rarely) there’s an issue with the WordPress update itself. Whatever the case, one of of the quickest solutions to bring your site back to normal is to downgrade WordPress back to the previous version.

Compatibility issues are one of the reasons I try to avoid plugins and themes that don’t get updated regularly. I don’t want to be stuck with an older version of WordPress just because one of my plugins or themes doesn’t work with the latest update. Before you go through the process of downgrading, I’d suggest checking to see if a plugin is what’s causing the issue. If it is, you can just disable the plugin until there’s an update for it. If it’s a problem with the theme though, that’s an entirely different story. That’s when you’ll want to consider downgrading your version of WordPress.

Before you downgrade, I’d highly recommend making sure you have a backup of your site just in case things don’t go as planned and everything gets screwed up. I’ve never run into an issue but I always have the feeling that the one time I downgrade and my site goes berserk, I won’t have a backup. There are tons of backup plugins for WordPress and your web host might/should be able to provide you with the latest backup they have.



The first thing you’re going to need is a previous WordPress release. You can download any of the previous WordPress versions here –> WordPress releases. Only downgrade down to the version before the newest one. Don’t go way back into the archives to version 1.1. Some of the older versions of WordPress have security issues that could put your site at risk.

Here’s how to downgrade WordPress to an older version.

MANUAL WORDPRESS DOWNGRADE TUTORIAL

STEP 1: DEACTIVATE ALL YOUR PLUGINS

After you’ve created a backup of your site and downloaded the WordPress version you want to downgrade to, it’s time to actually downgrade. The first thing you want to do is login to your WP Dashboard and deactivate all of your plugins.

Deactivate All WordPress plugins

STEP 2: LOGOUT OF WORDPRESS

After all your plugins have been deactivated, logout of WordPress.

STEP 3: USE AN FTP CLIENT AND LOCATE YOUR SITE’S WORDPRESS FILES

This step will require that you have an FTP client. An FTP client allows you to access all of the files on your site. I use FireFTP from Firefox and FileZilla is another very popular option. Both are free and you can’t go wrong with either. The images in this tutorial are from FireFTP. In your FTP client, locate your WordPress files (wp-admin, wp-content, etc.). In FireFTP, they will be the first thing you see when you open your site’s folder.

STEP 4: DELETE THE WP-ADMIN AND WP-INCLUDES FOLDERS

Delete both the wp-admin and wp-includes folders. Do not touch the wp-content folder! You can leave all of the other files alone because you will overwrite them in the next step.

how to downgrade wordpress step 4

STEP 5: TRANSFER THE FILES FROM THE PREVIOUS WP VERSION TO YOUR SITE WITH FTP

While you’re still in your FTP client, go into the folder where you have the WordPress version you want to downgrade to. Transfer over everything except the wp-contentfolder. After all the files have been transferred, your downgrade is finished.

how to downgrade wordpress step 5

STEP 6: UPDATE YOUR WORDPRESS DATABASE

Login to your WP Dashboard. You will be prompted to update your WordPress database. Click on “Update WordPress Database” and then click continue to login.

update wordpress database

Once you’re logged in, you should see that you’re running whatever version of WordPress that you downgraded to. Congrats!

A word of caution. I don’t recommend using older versions of WordPress when newer ones are available. Like I said in the beginning, a lot of the updates come with security patches to stop known security threats that could leave your site open to hackers.

If your theme isn’t compatible with the most current version of WordPress, contact the theme developer and let them know. If there’s no support offered for your theme, then you’ll want to switch to a different one that’s updated on a regular basis.

I hope you found my guide helpful. If you have any questions, feel free to leave a comment below!

%d bloggers like this: