How to forward a website to another url using PHP

There are several ways to accomplish this task, but the simplest to understand is to use php.

To do this, you need to create the page that will do the forwarding. This can be any page, as long as it ends in “.php”. If you are trying to redirect a domain, you’d create “index.php” inside the public_html directory.

Once you decide which page you will use, then create the file and enter the following text:

<?php
header(“Location: http://whereyouwant.com/to/go.html“);
?>

Where http://whereyouwant.com/to/go.html is the location that you want the page to forward to. You can use local values, ie: /page.html, or full urls as in the above example (http://..etc.)

Apache : Showing files in a directory

Showing files in a directory
If you want to list all files in a directory that doesn’t use an index.html (or index.php) file, you can create an .htaccess file with the following contents:

Options +Indexes

This will tell apache that you want to list all files in the directory.

Plesk Migration Manager is unable to connect to Plesk Agent installed on a remote server.

Source server has Plesk Migration agent installed. Plesk Migration Manager is installed on Plesk server. Plesk keeps displaying

Unable to upload scout: Unable to run migrmng: Unable to connect to remote host xxx.xxx.xxx.xxx. Please check if the remote server is available for connection and if the correct login and password are specified.

To successfully utilize Plesk Migration Manager it’s important to have the network setting configured correctly:

1. The following ports need to be open for PMM (add the required exceptions for firewall):

For PMM:tcp 6489 (by default or other custom)

For data transferring on Windows source servers:tcp 135tcp 139tcp 445udp 137udp 138

For data transferring on Linux source server:tcp: 22

2. Server’s network settings. “Client for Microsoft Networks” and “File and Printer Sharing for Microsoft Networks” must be present.

Start, Settings, Network Connections, Local Area Connection click Properties button. “Client for Microsoft Networks” and “File and Printer Sharing for Microsoft Networks” should be present. If they are not, they need to be installed.

You can test connection to server with PMM Agent using

Start, Run, type \\хxх.хxх.хxх.ххх\c$ and hit Enter

where xхх.xхх.хxх.ххх is the IP address of the source server.

And if “Network sharing” ports are opened you can access windows administrator’s share folders.

Plesk 9.3 Latest update of openssl breaks Parallels Panel :: Starting Plesk… failed

Latest update of the openssl package from CentOS breaks Parallels Panel 9.x. The following errors are displayed in the /var/log/sw-cp-server/error_log file when Panel is trying to start:

# tail /var/log/sw-cp-server/error_log
2010-04-07 01:56:38: (log.c.75) server started
2010-04-07 01:56:38: (network.c.336) SSL: error:00000000:lib(0):func(0):reason(0)
2010-04-07 01:57:59: (log.c.75) server started
2010-04-07 01:57:59: (network.c.336) SSL: error:00000000:lib(0):func(0):reason(0)
2010-04-07 01:57:59: (log.c.75) server started
2010-04-07 01:57:59: (network.c.336) SSL: error:00000000:lib(0):func(0):reason(0)
2010-04-07 02:13:38: (log.c.75) server started
2010-04-07 02:13:38: (network.c.336) SSL: error:00000000:lib(0):func(0):reason(0)
2010-04-07 02:13:38: (log.c.75) server started
2010-04-07 02:13:38: (network.c.336) SSL: error:00000000:lib(0):func(0):reason(0)

# service psa start
Starting xinetd service... done
Starting named service... done
Starting mysqld service... done
Starting postgresql service... not installed
Starting psa-spamassassin service... done
Plesk: Starting Mail Server... already started
Starting mail handlers tmpfs storage
Starting Plesk... failed
Starting drwebd service... not installed
#

To fix this you need to update Parallels Panel web-engine:

1. Download the appropriate package using the wget utility. Example for CentOS 5 x86:
#wget -c http://kb.parallels.com/Attachments/12669/Attachments/sw-cp-server-1.0-6.201004011105.centos5.i386.rpm

2. Install the downloaded package. Example for CentOS 5 x86:
#rpm -Uhv sw-cp-server-1.0-6.201004011105.centos5.i386.rpm

# rpm -Uhv sw-cp-server-1.0-6.201004011105.centos5.i386.rpm
Preparing... ########################################### [100%]
Stoppping SWsoft control panels server... stale pidfile. [ OK ]
1:sw-cp-server ########################################### [100%]
Starting SWsoft control panels server...[ OK ]

-bash-3.2# service psa start
Starting xinetd service... done
Starting named service... done
Starting mysqld service... done
Starting postgresql service... not installed
Starting psa-spamassassin service... done
Plesk: Starting Mail Server... already started
Starting mail handlers tmpfs storage
Starting Plesk... done
Starting drwebd service... not installed
-bash-3.2#

Uninstall APF

Sometimes we may require to remove APF from the server. Here is a guide which shows how to remove APF completely from the server.

Stop the firewall first
service apf stop
/bin/rm -rfv /etc/apf
Remove the cron for APF
/bin/rm -fv /etc/cron.daily/fw
/bin/rm -fv /etc/init.d/apf
lastly disable at startup
chkconfig apf off

This should remove APF completely from the server as we removed the APF daemon, cron and files.

PVA troubleshooting.

Linux/Unix, Management Node:
PVA status: # pvamn status
PVA restart: # pvamn restart
PVA (Control Center) status: # pvacc status
PVA (Control Center) restart: # pvacc restart
Special config file: /opt/pva/mn/bin/pva.conf
[log_folder] – Location of log files, default: /var/log/pva
[etc_folder] – Location of config files, default: /var/opt/pva/mn/etc
To change log level, find vzagent.conf location in pva.conf and change , then restart pvamn
3 – INFO level
4 – DEBUG level
Installation logs: /var/log/pva/setup/
To collect PVA Report run: # /opt/pva/mn/bin/pvareport.sh
Linux/Unix, Slave node:
PVA status: # pvaagent status
PVA restart: # pvaagent restart
PVA (Power Panel) status: # pvapp status
PVA (Power Panel) restart: # pvapp restart
Special config file: /opt/pva/agent/bin/pva.conf
[log_folder] – Location of log files, default: /var/log/pva
[etc_folder] – Location of config files, default: /vz/pva/agent/etc
To change log level, find vzagent.conf location in pva.conf and change , then restart pvaagent
3 – INFO level
4 – DEBUG level
Installation logs: /var/log/pva/setup/
To collect PVA Report run: # /opt/pva/agent/bin/pvareport.sh

PhpMyAdmin Stuck at Login screen with no errors !

This is a possible issue when the path to save php_session is not correctly set :

The directory for storing session does not exists or php do not have sufficient rights to write to it.

To define the php_session directory simply add the following line to the php.ini :

session.save_path=”/tmp/php_session/”

And give write rights to the http server.

usually, the http server run as user daemon in group daemon. If it is the case, the following commands will make it :

chown -R :daemon /tmp/php_session

chmod -R g+wr /tmp/php_session

restart http server.

How to change time zone in Linux !

1. Log in as root, check which timezone your machine is currently using by executing `date`. You’ll see something like “Mon Feb 12 05:09:00 CST 2007″, CST in this case is the current timezone.

2. Change to the directory to /usr/share/zoneinfo, here you will find a list of time zone regions. Choose the most appropriate region. If you live in Canada or the US this directory is the “Americas” directory.

3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as `mv /etc/localtime /etc/localtime-old`.

4. Create a symbolic link from the appropiate timezone to /etc/localtime. Example: `ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime`.

5. If you have the utility rdate, update the current system time by executing `rdate -s time.nist.gov` or `rdate -s rdate.cpanel.net`

6. Synchronize hardware clock with system clock by executing: ` /sbin/hwclock –systohc`

🙂

What is APF (Advanced Policy Firewall)? APF Firewall

APF is a policy based iptables firewall system designed for ease of use and configuration. It employs a subset of features to satisfy the veteran Linux user and the novice alike. Packaged in tar.gz format and RPM formats, make APF ideal for deployment in many server environments based on Linux. APF is developed and maintained by R-fx Networks: http://www.rfxnetworks.com/apf.php

This guide will show you how to install and configure APF firewall, one of the better known Linux firewalls available.10

Requirements:
– Root SSH access to your server

Lets begin!
Login to your server through SSH and su to the root user.

cd /root/downloads or another temporary folder where you store your files.

2. wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz

3. tar -xvzf apf-current.tar.gz

4. cd  apf-9.6-5/ or whatever the latest version is.

5. Run the install file: ./install.sh
You will receive a message saying it has been installed

Installing APF 9.6-5: Completed.
Installation Details:
Install path:         /etc/apf/
Config path:          /etc/apf/conf.apf
Executable path:      /usr/local/sbin/apf
Other Details
Listening TCP ports: 53,2086,2087,3306
Listening UDP ports: 53,39437

Note: These ports are not auto-configured; they are simply presented for information purposes. You must manually configure all port options.

6. Lets configure the firewall: nano -w /etc/apf/conf.apf
We will go over the general configuration to get your firewall running. This isn’t a complete detailed guide of every feature the firewall has. Look through the README and the configuration for an explanation of each feature.

We like to use DShield.org’s “block” list of top networks that have exhibited
suspicious activity.
FIND: USE_DS="0"
CHANGE TO: USE_DS="1"

7. Configuring Firewall Ports:

Cpanel Servers
We like to use the following on our Cpanel Servers

Common ingress (inbound) ports
# Common ingress (inbound) TCP ports -3000_3500 = passive port range for Pure FTPD
IG_TCP_CPORTS="21,22,25,53,80,110,143,443,2082,2083, 2086,2087, 2095, 2096,3000_3500"
#
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="53"

Common egress (outbound) ports
# Egress filtering [0 = Disabled / 1 = Enabled]
EGF="1"

# Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,80,443,43,2089"
#
# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53"

Ensim Servers
We have found the following can be used on Ensim Servers – although we have not tried these ourselves as I don’t run Ensim boxes.

Common ingress (inbound) ports
# Common ingress (inbound) TCP ports
IG_TCP_CPORTS="21,22,25,53,80,110,143,443,19638"
#
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="53"

Common egress (outbound) ports
# Egress filtering [0 = Disabled / 1 = Enabled]
EGF="1"

# Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,80,443,43"
#
# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53"

Save the changes: Ctrl+X then Y

8. Starting the firewall
/usr/local/sbin/apf -s

Other commands:
usage ./apf [OPTION]
-s|--start ......................... load firewall policies
-r|--restart ....................... flush & load firewall
-f|--flush|--stop .................. flush firewall
-l|--list .......................... list chain rules
-st|--status ....................... firewall status
-a HOST CMT|--allow HOST COMMENT ... add host (IP/FQDN) to allow_hosts.rules and
immediately load new rule into firewall
-d HOST CMT|--deny HOST COMMENT .... add host (IP/FQDN) to deny_hosts.rules and
immediately load new rule into firewall

9. After everything is fine, change the DEV option
Stop the firewall from automatically clearing itself every 5 minutes from cron.
We recommend changing this back to “0” after you’ve had a chance to ensure everything is working well and tested the server out.

nano -w /etc/apf/conf.apf

FIND: DEVM="1"
CHANGE TO: DEVM="0"

10. Checking the APF Log

Will show any changes to allow and deny hosts among other things.
tail -f /var/log/apf_log