Understand absolute and relative paths

16 Apr, 2010

Joomla configuration file showing paths
When dealing with a web server, it is important to understand the relationships of one file to another, those files to the server, and those files to the Web. When creating hyperlinks or configuring various website options, particularly PHP or Perl scripts, you will need to know both absolute paths and relative paths.

Absolute Paths

There are two types of absolute paths you will encounter. The first is directly related to the Web and the website’s domain name. For example, the path to myfile.html might be:

http://www.mywebsite.info/folder/folder3/myfile.html

On the server, the absolute path would be something like:

/home/user/public_html/folder/folder3/myfile.html (useful in configuring scripts)

Relative Paths

With a relative path, the server looks at where the user currently is then moves either forward deeper into a directory or goes up to any number of parent directories. For example:

folder3/myfile.html

Inside the html file, you might need to link to an image in a directory that is two steps higher:

../../images/myimage.jpg (which is the absolute path: http://www.mywebsite.info/images/myimage.jpg)

With this knowledge, you should be able to link within documents and configure scripts.

(0) Comment Categories : Web Design, Web servers
Tag: , , , , , , , ,

What people should know about Windows servers

30 Mar, 2010

Joomla screenshot
Aside from writing, I also develop websites for clients on a freelance basis. In the ideal scenario, I get contacted by an interested client who has neither a domain name nor a current web hosting company. I can then steer that client to the host and domain provider I think is best and will work well with Joomla or whatever content management system I use.

Unfortunately, many clients come with their own baggage. More often than not, it includes a domain hosted by a company like GoDaddy and possibly a current website that is less than stellar. The worst situation that I ever encountered was a client who had chosen to use GoDaddy’s hosting service with a Windows server. Anyone who has tried to use PHP content management systems with Windows is probably already cringing at the thought.

Aside from the usual problems with GoDaddy’s control panel, I had to content with Windows and its strange compatibility issues with PHP. Theoretically, it should work fine with Joomla, but that requires proper configuration, something GoDaddy failed to do. Mind you, the Joomla installation was automatic from their own control panel, but it still never worked quite right. In the end, the client settled for a less-than-perfect site. My advice to anyone who wants a website: ask those who know first before you make purchases.

Photo Source: Flickr

(0) Comment Categories : Web Design, Web Hosting
Tag: , , , , , ,

Scripting language roundup

19 Mar, 2010

Scripting languages books
Every website has code. HTML code is the backbone of the Web, but for more advanced features on a website and especially for web applications, you need a good scripting language. Here are a few, some basic, some more complex that are free for Linux servers:

Javascript – Built into web browsers, this is a client-side language. The down side is that end users might disable it or not have it fully supported.

Perl – Old, reliable, and trusted, Perl comes with many Linux distributions, but it is not the easiest to setup and maintain.

PHP – Like Perl, it is a server-side language and has become increasingly popular. It can be run inside of Apache or as its own executable.

Python – Many programmers prefer Python for more advanced applications, although it does not dominate the Web.

JSP – Normally Java apps run on the client side, but with an Apache Tomcat HTTP server, you can have Java Server Pages (JSP).

In a future post, we will learn how to setup each on a dedicated server.

Photo Source: Flickr

(0) Comment Categories : Web Hosting, Web servers
Tag: , , , , ,

New server setup

3 Mar, 2010

server rack
Question: I want to setup my own server. What software and tools will I need?

Answer: The first major decision to make after you have purchased server hardware is what operating system to use. Many servers come with one already, but if yours does not, you will need to decide on one. Linux or other Unix variants, such as BSD or Solaris are by far the most popular, but there are also many Windows servers out there. If you are on a limited budget, go with a free Linux distribution, such as CentOS.

The next thing to choose is the web server. Choices include Apache, Nginx, and Lighttpd. After that, you will probably one a database server such as MySQL or PostgreSQL Finally, you will want a web-based control panel. Depending on the one you choose, it might also install its own versions of Apache, PHP, and MySQL.

There are many control panel solutions on the market, and most of them are commercial. Popular control panels includ cPanel and Plesk. There are also free solutions available like Virtualmin. Decide what you need for whatever type of websites you plan to have and then choose the software that meets those needs.

Photo: Flickr

(0) Comment Categories : VPS & Dedicated, Web servers
Tag: , , , , , , ,

How to redirect a web page without .htaccess

26 Feb, 2010

PHP logo
Question: I have a shared hosting account, but my web host has disabled my ability to make .htaccess files. How can I create redirects on my site?

Answer: First of all, it is a bad practice for a web hosting provider to completely disable .htaccess. You should probably consider getting a new host, but if that is not an immediate option, you can use PHP to redirect.

First, replace all of the code in the file you want to redirect to this:

Change the address to reflect your real domain and the correct filename for your new page.

That’s it! There is no second step. You need to make sure that there is no text before the PHP code, not even the <html> tag. Now, every time users visit the old page, they will be automatically redirected to the new one.

(0) Comment Categories : Web Hosting
Tag: , , , ,

How to compare two files in Linux

16 Feb, 2010

diff command
Question: I have two scripts in a directory on my server. One is the right one and one is not, but I do not remember which is which. How can I compare the two files?

Answer: Linux and UNIX-like operating systems usually come with a comparison command called “diff”. This command will display line-by-line differences between two files. It is useful for software developers, but web developers and web application managers will find it useful as well.

To use it, just enter:

diff script1.php script2.php

It will search through both PHP scripts and find any lines that are different. The output will look something like this:

if(!function_exists('add_action')){
header('HTTP/1.0 404 Not Found');
header('Location: ../../');
> exit();
}

In the first file “exit();” is not present, while the second file correctly contains it. Tomorrow we will learn how to merge the two differing files into one correct file.

(0) Comment Categories : Software, VPS & Dedicated
Tag: , , , , ,

Micro-blogging on your own domain with StatusNet

11 Feb, 2010

StatusNet
Twitter has become very popular in a short amount of time. With it, users can post short updates about what they are currently doing, working on, thinking, or viewing/accessing. For businesses, it is a good way to communicate with others who might not be in the same office or even the same city or country. The downside to this is that Twitter is used by so many others for other purposes, and users are often inundated with requests.

Running a micro-blogging server of your own might be very appealing, particularly if you only need it for a company’s business and do not want outsiders to view it. While hosted solutions like Twitter offer privacy options, you would still be trusting your security to a third party. StatusNet is a free micro messaging platform that powers the also popular Identi.ca.

You can host it on your own domain, share files, create groups, add plug-ins and applications, and access it via both desktop computers and mobile devices. It is a PHP application that stores data in MySQL databases. StatusNet is free software released under the GNU AGPL and is available for download directly from the project’s website.

(0) Comment Categories : Software, Web Hosting, Web servers
Tag: , , , , , , ,

How to set resource limits on PHP

8 Feb, 2010

PHP logoIn a previous post, we learned how to increase the memory limit on PHP by editing the php.ini file. But limits exist for a reason, and although you would probably love to give every process, every script, and every website unlimited CPU cycles, memory, and bandwidth, it just isn’t possible.

To begin editing, open /etc/php.ini in your text editor of choice. For example:

# nano /etc/php.ini

Look for the following values and change them to fit your requirements for your server. Below are just suggested values:

max_execution_time = 30
max_input_time = 30
memory_limit = 40M
post_max_size = 8M
upload_max_filesize = 2M

You may need to adjust the actual size limits to meet the requirements of certain content management systems or scripts, but be sure to not get carried away with being too liberal.

(0) Comment Categories : Software, VPS & Dedicated, Web servers
Tag: , , , , , ,

Installing software on an OpenSolaris server

20 Jan, 2010

OpenSolaris logo
Continuing with our tour of server operating systems, today we will take a look at Sun Microsystems’ OpenSolaris, the free and open source version of the popular Unix-based Solaris OS. Those who experience with other Unix or Linux servers should find much of OpenSolaris familiar. Nevertheless, there are some key differences.

One of the first things you will want to do with a new OpenSolaris dedicated server would be to install software. The command for installing packages is “pkg”. For example, if you wanted to install mysql, you would type from the command line:

pfexec pkg install SUNWmysql

To install the complete PHP, MySQL, and Apache stack, install the meta package called “amp”.

pfexec pkg install amp

The same command “pkg install” can be used for upgrading packages, and it will automatically upgrade any of the packages dependencies as well. For more information about installing packages in OpenSolaris, see the Sun website.

(0) Comment Categories : VPS & Dedicated, Web servers
Tag: , , , , , ,

WampServer on Windows

18 Jan, 2010

WampServer
We have spent a great deal of blog space learning about Linux servers and how to optimize them, but Linux is certainly not the only kid on the block. This week we will look at some other operating systems and how they interact with the Web. First up is Microsoft Windows.

The standard web server on Windows comes with Microsoft’s IIS (Internet Information Service), but some of us still prefer open source technologies even on Windows. LAMP (Linux Apache MySQL and PHP) has become famous for its stability and reliability, but some people prefer to replace the L with a W. What you get is WAMP, and there is free software available that will install WAMP for you automatically on Windows. It is called WampServer.

WampServer will install versions of Apache, MySQL, and PHP on your Windows system with little hassle. The site does not seem to specify which versions of Windows it supports, but it should work with any Windows server. In addition to the base release, there are also addons that users can install to extend the application’s usability. WampServer is free software released under the GNU General Public License.

Source: WampServer

(0) Comment Categories : Software, Web Hosting, Web servers
Tag: , , , , , ,