Host Multiple Domains: Setting Up Virtual Hosts With Webmin
If you want to run multiple websites from your VPS, then you can use Apache's support for Virtual Hosts.
First up, where are you going to put your HTML files? You can put the files anywhere you want, but one useful convention is to have a Linux user per virtual host. And to put the HTML files under that user's home directory. This is especially convenient if the user will be uploading files via FTP, since if you chroot the user's FTP access then they can only access files in their home directory.
To setup a user, run something like this:
username=TheDomainNameWithoutAnyDots
adduser $username
passwd $username
mkdir -p ~$username/htdocs
chown -R $username ~$username
Then, to create a virtual host using Webmin:
•Go to your Webmin control panel.
•Upgrade to the latest version of webmin (required if you are running a version older than 1.080, and normally advisable regardless).
•Go to servers.
•Go to Apache WebServer.
•In the 'Create a New Virtual Server' section select "Any Address" (so you do not end up with a hard coded IP addresses in your conf file)
•Enter 80 for Port (and select the last radio button). This way the VirtualHost will co-exist with any SSL-enabled virtual hosts you add later on. SSL-enabled VirtualHosts need to listen on port 443.
•In the "Document Root" field enter where the virtual host HTML files will be. For example, /home/vhostdomain.com/htdocs.
•For "Server Name" enter the domain name for which you want to serve pages. e.g. "vhostdomain.com"
After you have created the Virtual Host, there are a few other things you may wish to edit.
For example, click on the Virtual Host, and go to Networking and Addresses. Enter an "Alternate virtual server names" of *.YourOtherDomain.com. With this setting, your virtual host will serve pages for http://yourotherdomain.com/ as well as http://www.yourotherdomain.com/.
At this point you may also wish to set other options like "Log Files", so the log files for the Virtual Host end up in separate log file from the main server's log files.
To activate your changes, click "Apply Changes" on the main Apache Webmin page.
Of course, be sure to configure your DNS server so the virtual host domain name points to your server's IP address.
Webmin creates a VirtualHost directive in the Apache config file (/etc/httpd/conf/httpd.conf). An example VirtualHost directive looks like this:
<VirtualHost *:80>
DocumentRoot /home/vhostdomain.com/htdocs
ServerName vhostdomain.com
ServerAlias *.vhostdomain.com
</VirtualHost>
See http://httpd.apache.org/docs/2.2/vhosts/examples.html for some more VirtualHost examples.
Resolving: [warn] _default_ VirtualHost overlapon port 80, the first has precedence
If you get this error when restarting Apache, un-comment the NameVirtualHost *:80 line in /etc/httpd/conf/httpd.conf.
Resolving: 403 Forbidden
Unix needs to be able to 'execute' directories in order to open them (not 'read' them as you would expect). If you get a forbidden error, make sure that the directory containing your HTML files and each of its parent directories has chmod o+x set on it. The following script should do that for you:
dir=/home/somevhostdomain.com/htdocs/;
while true; do
# the exit case when we get to the top level directory /
if [ -z "$dir" -o "$dir" = "/" ]; then
break;
fi;
echo chmodding o+x $dir;
# make the directory exectuable (openable) by others
chmod o+x $dir;
# go 'up' a directory
dir=`dirname $dir`;
done
Redirecting an Incoming Request
Somtimes you have content which has been moved or deleted, but you'd like to return something to the client instead of the dreaded 404 response. In this case, you can use the Redirect directive to specify what you want to do:
# Temporary Redirect (code 302)
Redirect /your/path/file.html http:\//yourdomain.com/some/path/file.html
Redirect temp /your/path/file.html http:\//yourdomain.com/some/path/file.html
# Permanent Redirect (code 301)
Redirect permanent /your/path/file.html http:\//yourdomain.com/some/path/file.html
# Moved (code 303)
Redirect seeother /your/path/file.html http:\//yourdomain.com/some/path/file.html
# Gone (code 410)
Redirect gone /your/path/file.html
Note, these do not have to be static html files; the incoming and redirected requests could be to any resource type.
Karnav Thakar. MCP, MCSA, MCSE, MSITP, CHFI, ECA
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Monday, 25 July 2011
Friday, 8 July 2011
How to update PHP 5.1.x to 5.2.x
Summary
This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:
# rpm -qa |grep php
php-common-5.1.6-15.el5.i386
php-cli-5.1.6-15.el5.i386
php-5.1.6-15.el5.i386
php-pdo-5.1.6-15.el5.i386
php-bcmath-5.1.6-15.el5.i386
php-ldap-5.1.6-15.el5.i386
php-devel-5.1.6-15.el5.i386
php-gd-5.1.6-15.el5.i386
php-xml-5.1.6-15.el5.i386
php-mbstring-5.1.6-15.el5.i386
php-mysql-5.1.6-15.el5.i386
php-dba-5.1.6-15.el5.i386
As long as you're using the standard PHP packages on your CentOS server you won't need to do anything extra. If you're using extra PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find updated versions of them.
Add the development repositories
First thing we need to do is add the development repositories to yum. When we add the development repository we're going to configure it so it only pulls PHP packages. To start we'll need create a new yum repository configuration file (use your favorite editor):
# /etc/yum.repos.d/CentOS-Testing.repo
Copy/paste the following into this file:
# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*
Make sure to remove any spaces at the start of each line, then save and close the file and you're done.
Update PHP packages
Before updating your PHP packages you'll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:
# rpm -qa |grep php
Now you can use yum to update the PHP packages on your system:
# yum update
You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.2.x. If that is acceptable type "y" to continue and let yum update the packages.
Once yum has completed restart Apache:
# service httpd restart
To verify the update is working create a simple testing.php in your www directory with the following source code:
< ?php
phpinfo();
?>
and open it in a web browser. The new PHP version should be reflected at the top of the page.
Conclusion
You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.
# rpm -qa |grep php
php-cli-5.2.6-2.el5s2
php-mbstring-5.2.6-2.el5s2
php-devel-5.2.6-2.el5s2
php-pdo-5.2.6-2.el5s2
php-gd-5.2.6-2.el5s2
php-dba-5.2.6-2.el5s2
php-common-5.2.6-2.el5s2
php-bcmath-5.2.6-2.el5s2
php-xml-5.2.6-2.el5s2
php-pear-1.5.1-2.el5s2
php-ldap-5.2.6-2.el5s2
php-5.2.6-2.el5s2
php-mysql-5.2.6-2.el5s2
# php -v
PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:
# rpm -qa |grep php
php-common-5.1.6-15.el5.i386
php-cli-5.1.6-15.el5.i386
php-5.1.6-15.el5.i386
php-pdo-5.1.6-15.el5.i386
php-bcmath-5.1.6-15.el5.i386
php-ldap-5.1.6-15.el5.i386
php-devel-5.1.6-15.el5.i386
php-gd-5.1.6-15.el5.i386
php-xml-5.1.6-15.el5.i386
php-mbstring-5.1.6-15.el5.i386
php-mysql-5.1.6-15.el5.i386
php-dba-5.1.6-15.el5.i386
As long as you're using the standard PHP packages on your CentOS server you won't need to do anything extra. If you're using extra PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find updated versions of them.
Add the development repositories
First thing we need to do is add the development repositories to yum. When we add the development repository we're going to configure it so it only pulls PHP packages. To start we'll need create a new yum repository configuration file (use your favorite editor):
# /etc/yum.repos.d/CentOS-Testing.repo
Copy/paste the following into this file:
# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*
Make sure to remove any spaces at the start of each line, then save and close the file and you're done.
Update PHP packages
Before updating your PHP packages you'll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:
# rpm -qa |grep php
Now you can use yum to update the PHP packages on your system:
# yum update
You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.2.x. If that is acceptable type "y" to continue and let yum update the packages.
Once yum has completed restart Apache:
# service httpd restart
To verify the update is working create a simple testing.php in your www directory with the following source code:
< ?php
phpinfo();
?>
and open it in a web browser. The new PHP version should be reflected at the top of the page.
Conclusion
You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.
# rpm -qa |grep php
php-cli-5.2.6-2.el5s2
php-mbstring-5.2.6-2.el5s2
php-devel-5.2.6-2.el5s2
php-pdo-5.2.6-2.el5s2
php-gd-5.2.6-2.el5s2
php-dba-5.2.6-2.el5s2
php-common-5.2.6-2.el5s2
php-bcmath-5.2.6-2.el5s2
php-xml-5.2.6-2.el5s2
php-pear-1.5.1-2.el5s2
php-ldap-5.2.6-2.el5s2
php-5.2.6-2.el5s2
php-mysql-5.2.6-2.el5s2
# php -v
PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
Monday, 13 June 2011
Asterisk Backup Restore
Asterik Backup and Restore
Go to theSQL file path
cd /root/
run thi command : gunzip <SQL File name.sql.gz>
mysql -u <username/root> -database name> < SQL file name/sql
Like this mysql -u root -p a2billing <123456.sql
Go to theSQL file path
cd /root/
run thi command : gunzip <SQL File name.sql.gz>
mysql -u <username/root> -database name> < SQL file name/sql
Like this mysql -u root -p a2billing <123456.sql
Subscribe to:
Posts (Atom)
ISM Cyber Security Terms
ISM Cyber Security Terms
-
--> Phase 3 :- Installation of Windows Exchange server standard 2007 SP1 & Move Mailbox, Installtion/Transfer of Commercial Certi...
-
If you have PABX server like Asterisk / Free PBX / Elastix and want to feature to listen / whisper / barge to other calls. ChanSpy can gi...