human growth hormone side effects
Webmaster Resources
 

How to install php-imagick on CentOS 5

Filed under :Linux

ImageMagick is a software suite to create, edit, compose or convert bitmap images. To use this utility in PHP, you’ll need to install ImageMagick Linux package and also build and install a PHP extension.

Prerequisite for installing imagick PHP extension is php-pear and gcc packages, so let’s get those packages installed.

# yum install php-pear gcc

Now, that you have php-pear and gcc, you may install ImageMagick packages.

# yum install ImageMagick ImageMagick-devel
# pecl install imagick

Note: You’ll not be able to run pecl if you don’t have php-pear package installed. To compile imagick, you’ll need a GCC compiler as well.

By running the command, you’ll install ImageMagick and PHP extension module imagick.so in the /usr/lib/php/modules folder. If you have a 64-bit machine, the modules directory will be /usr/lib64/php/modules.

Edit the /etc/php.d/imagick.ini, and add the following line.

extension=imagick.so

Restart apache, by …

# service httpd restart

That’s all there is to it.

Did you like this? Share it:

PHP $_SERVER environment variable

Filed under :Linux

PHP provides a large number of predefined variables to all scripts, and $_SERVER array is commonly used to refer server-specific environment information. Per PHP.net documentation, the $_SERVER variable is defined as:

Description
$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the ยป CGI/1.1 specification, so you should be able to expect those.

$HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)

Indices

$_SERVER['PHP_SELF']: The filename of the currently executing script, relative to the document root. No query string will be returned. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php?abc=123 would be /test.php. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

http://example.com/server.php?a=1&b=2&c=3  ==>  /server.php

$_SERVER['GATEWAY_INTERFACE']: What revision of the CGI specification the server is using; i.e. ‘CGI/1.1′.

http://example.com/server.php?a=1&b=2&c=3  ==>  CGI/1.1

$_SERVER['SERVER_ADDR']: The IP address of the server under which the current script is executing.

http://example.com/server.php?a=1&b=2&c=3  ==>  69.67.216.167

$_SERVER['SERVER_NAME']: The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

http://example.com/server.php?a=1&b=2&c=3  ==>  example.com

$_SERVER['SERVER_SOFTWARE']: Server identification string, given in the headers when responding to requests.

http://example.com/server.php?a=1&b=2&c=3  ==>  Apache/2.2.3 (CentOS)

$_SERVER['SERVER_PROTOCOL']: Name and revision of the information protocol via which the page was requested; i.e. ‘HTTP/1.0′;

http://example.com/server.php?a=1&b=2&c=3  ==>  HTTP/1.1

$_SERVER['SERVER_METHOD']: Which request method was used to access the page; i.e. ‘GET’, ‘HEAD’, ‘POST’, ‘PUT’. (Note: PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.)

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['REQUEST_TIME']: The timestamp of the start of the request. Available since PHP 5.1.0.

http://example.com/server.php?a=1&b=2&c=3  ==>  1307744457

$_SERVER['QUERY_STRING']: The query string, if any, via which the page was accessed.

http://example.com/server.php?a=1&b=2&c=3  ==>  a=1&b=2&c=3

$_SERVER['DOCUMENT_ROOT']: The document root directory under which the current script is executing, as defined in the server’s configuration file.

http://example.com/server.php?a=1&b=2&c=3  ==>  /var/www/html

$_SERVER['HTTP_ACCEPT']: Contents of the Accept: header from the current request, if there is one.

http://example.com/server.php?a=1&b=2&c=3  ==>  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

$_SERVER['HTTP_ACCEPT_CHARSET']: Contents of the Accept-Charset: header from the current request, if there is one. Example: ‘iso-8859-1,*,utf-8′.

http://example.com/server.php?a=1&b=2&c=3  ==>  ISO-8859-1,utf-8;q=0.7,*;q=0.3

$_SERVER['HTTP_ACCEPT_ENCODING']: Contents of the Accept-Encoding: header from the current request, if there is one. Example: ‘gzip’.

http://example.com/server.php?a=1&b=2&c=3  ==>  gzip,deflate,sdch

$_SERVER['HTTP_ACCEPT_LANGUAGE']: Contents of the Accept-Language: header from the current request, if there is one. Example: ‘en’.

http://example.com/server.php?a=1&b=2&c=3  ==>  en-US,en;q=0.8

$_SERVER['HTTP_CONNECTION']: Contents of the Connection: header from the current request, if there is one. Example: ‘Keep-Alive’.

http://example.com/server.php?a=1&b=2&c=3  ==>  keep-alive

$_SERVER['HTTP_HOST']: Contents of the Host: header from the current request, if there is one.

http://example.com/server.php?a=1&b=2&c=3  ==>  example.com

$_SERVER['HTTP_REFERER']: The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['HTTP_USER_AGENT']: Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page’s output to the capabilities of the user agent.

http://example.com/server.php?a=1&b=2&c=3  ==>  Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30

$_SERVER['HTTPS']: Set to a non-empty value if the script was queried through the HTTPS protocol. (Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.)

http://example.com/server.php?a=1&b=2&c=3  ==>  

https://example.com/server.php?a=1&b=2&c=3  ==>  On

$_SERVER['REMOTE_ADDR']: The IP address from which the user is viewing the current page.

http://example.com/server.php?a=1&b=2&c=3  ==>  24.15.238.72

$_SERVER['REMOTE_HOST']: The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user. (Note: Your web server must be configured to create this variable. For example in Apache you’ll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().)

http://example.com/server.php?a=1&b=2&c=3  ==>  49857

$_SERVER['REMOTE_PORT']: The port being used on the user’s machine to communicate with the web server.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['SCRIPT_FILENAME']: The absolute pathname of the currently executing script. (Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.)

http://example.com/server.php?a=1&b=2&c=3  ==>  /var/www/html/server.php

$_SERVER['SERVER_ADMIN']: The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.

http://example.com/server.php?a=1&b=2&c=3  ==>  admin@topwebhosts.org

$_SERVER['SERVER_PORT']: The port on the server machine being used by the web server for communication. For default setups, this will be ’80′; using SSL, for instance, will change this to whatever your defined secure HTTP port is.

http://example.com/server.php?a=1&b=2&c=3  ==>  80

$_SERVER['SERVER_SIGNATURE']: String containing the server version and virtual host name which are added to server-generated pages, if enabled.

http://example.com/server.php?a=1&b=2&c=3  ==>  Apache/2.2.3 (CentOS) Server at www.topwebhosts.org Port 80

$_SERVER['PATH_TRANSLATED']: Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping. (Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it’s set to the same value as the SCRIPT_FILENAME server variable when it’s not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined. Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.)

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['SCRIPT_NAME']: Contains the current script’s path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

http://example.com/server.php?a=1&b=2&c=3  ==>  /server.php

$_SERVER['REQUEST_URI']: The URI which was given in order to access this page; for instance, ‘/index.html’.

http://example.com/server.php?a=1&b=2&c=3  ==>  /server.php?a=1&b=2&c=3

$_SERVER['PHP_AUTH_DIGEST']: When doing Digest HTTP authentication this variable is set to the ‘Authorization’ header sent by the client (which you should then use to make the appropriate validation).

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['PHP_AUTH_USER']: When doing HTTP authentication this variable is set to the username provided by the user.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['PHP_AUTH_PW']: When doing HTTP authentication this variable is set to the password provided by the user.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['AUTH_TYPE']: When doing HTTP authenticated this variable is set to the authentication type.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['PATH_INFO']: Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff.

http://example.com/server.php?a=1&b=2&c=3  ==>  

$_SERVER['ORIG_PATH_INFO']: Original version of ‘PATH_INFO’ before processed by PHP.

http://example.com/server.php?a=1&b=2&c=3  ==>  

To learn the differences between the PHP_SELF, SCRIPT_NAME and REQUEST_URI, please consult http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm.

Did you like this? Share it:

How to install Subversion on SuSE Linux?

Filed under :Linux

I’ve had a chance to install Subversion on Windows machines in the past, but this is my first try on SuSE Linux. The process is pretty straight forward, and it’s fairly easy to follow. Here is the run down summary of how to get started.

1. Use Zypper to install the following modules:

# zypper install subversion subversion-tools apache2

2. Once you have required software modules, installed browse the following README file to setup your subversion repositories.

less /usr/share/doc/packages/subversion/README.SuSE

That’s all! Shouldn’t take anymore than an hour to complete the job.

Did you like this? Share it:

Assigning name/value pair from a single element array to variables

Filed under :Linux

How do you extract name/value pair of an associative array into PHP variables? Whether it’s a single element array, or multiple element array the procedure is identical.

$coins = array(“penny” => 1, “nickle” => 5, “dime” => 10, “quarter” => 25);
foreach ($coins as $name => $value) {
echo “$name -> $value\n”;
}

while(list($name, $value) = each($coins)) {
echo “$name -> $value\n”;
}

If you have a multi-dimentional array with a single element in an array for multi-element relationship (name/name/value, or name/value/value), you may use the following:

$family = array(
“dad” => array(“scott” => 45),
“mom” => array(“karen” => 43),
“son1″ => array(“ryan” => 16),
“daughter” => array(“cindy” => 18),
“son2″ => array(“andrew” => 13));

foreach($family["dad"] as $name => $age);
echo “(Dad) name: $name, age: $age\n”;

list($name, $age) = each($family["mom"])
echo “(Mom) name: $name, age: $age\n”;

Basically, the foreach and list/each commands achieve the same goal.

Did you like this? Share it:

How do I extract information from an SSL key and certificate?

Filed under :Linux

An SSL certificate contains the information about issuer, valid dates, subject and other cryptic information. The openssl x509 subcommand may be used to retrieve those information from a SSL certificate.

# The “-text” option will output full breadth of certificate information.
bash# openssl x509 -text -in server.crt

# The “-issuer” option will show issuer.
bash# openssl x509 -noout -in server.crt -issuer

# The “-subject” option will show Organizational information.
bash# openssl x509 -noout -in server.crt -subject

# The “-dates” option will show valid dates
bash# openssl x509 -noout -in server.crt -dates

# “-hash” and “-fingerprints” may also be used conjunction with other options.
bash# openssl x509 -noout -in server.crt -hash -fingerprint -issuer

Did you like this? Share it:

How do I disable ping response on Linux?

Filed under :Linux, Networking

To disable responses to a ICMP ping request, the following two kernel parameters can be added to the /etc/sysctl.conf file.

# Disable ping response
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 1

To apply the changes, perform the following command.

# sysctl -p

To make it one time change, run the following command.

echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

Did you like this? Share it:

Install spamassassin with sendmail

Filed under :Linux, Perl

Documentation http://spamassassin.apache.org/

1. Install spamassassin on the server

# yum install spamassassin

2. Install required perl CPAN modules

# perl -MCPAN -e shell
cpan> install Digest::SHA1
cpan> install HTML::Parser
cpan> Install option perl modules…

2. Edit spamassassin configuration in /etc/mail/spamassassin/local.cf .

# Encapsulate spam in an attachment (0=no, 1=yes, 2=safe)
report_safe 0

# Enable the Bayes system
use_bayes 1

# Enable Bayes auto-learning
bayes_auto_learn 1

# Enable or disable network checks
skip_rbl_checks 0
use_razor2 1
use_dcc 1
use_pyzor 1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_languages all

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales all

3. Tell procmail to run spamc on everyone’s mail. Add these to /etc/procmailrc :

DROPPRIVS=yes

:0fw
| /usr/bin/spamc

4. Restart spamassassin

# service restart spamassassin

Did you like this? Share it:

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443

Filed under :Linux

When starting httpd service, the following error message appears and the service failed to start.

# service httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs

The error message means that when httpd tried to start, some other process was already listening on 443. To see what other processes are using port 443, the following two commands may be used:

# netstat -A inet -lnp
# lsof -i tcp:443

Using the commands shown above, find a process that is listening on port 443 and kill that process. And, restart the http daemon.

Did you like this? Share it:

Apache mod_vhost_alias module fails to set DOCUMENT_ROOT

Filed under :Apache, Linux

Mass virtual hosting using mod_vhost_alias or mod_rewrite module simplifies pattern-based virtual hosting. However, there is a major problem if your virtual host application makes use of the DOCUMENT_ROOT environment variable. According to the Apache documentation, the mod_vhost_alias does NOT correctly sets the DOCUMENT_ROOT variable and hence pontentially break PHP web applications that makes use of this environment variable. It seems that one logical thing to do is to use the VirtualDocumentRoot to map DOCUMENT_ROOT variable, but current mod_vhost_alias does NOT implement this function and it is very unlikely that it will any time soon.

To best way to solve this problem is to applying a patch for mod_vhost_alias.c, which is written by a person with an email address (cbs[at]cts.ucla.edu) that dynamically sets DOCUMENT_ROOT environment variable. The behavior is controlled by setting SetVirtualDocumentRoot to “on” or “yes”. The original patch can be found apache bugzilla. To apply the patch, you’ll have to rebuild the version of apache you’re running. There is no easy way to rebuild mod_vhost_alias module only.

1. To rebuild apache, you’ll need a source RPM for your platform. We’re running Fedora Core 1, so we’ve downloaded the version from Fedora Legacy. RPM Find provides binary and source RPMs for various platforms.

2. Install source RPM by running, rpm -i httpd-2.0.x.y.z.tar.gz. Where x.y.z is the version of Apache you are installing. The source RPM will be installed in the rpm source directory. For redhat (and Fedora), the location of source rpm is /usr/src/redhat.

3. The next step is to modify the mod_vhost_alias.c as specified in the patch above, and rebuild the binaries. To get the mod_vhost_alias.c file, you’ll need to untar httpd-2.0.x.y.z.tar file locaated in the /usr/src/redhat/SOURCE directory. Extract the tar archive in the temporary directory, and edit the mod_vhost_alias.c file located in the ./httpd-2.0.x/modules/mappers directory.

4. After modifying the mod_vhost_alias.c file, tar up the file and place it in the /usr/src/redhat/SOURCE folder. The new file replaces the old httpd-2.0.x.y.z.tar file.

5. Now, we need to rebuild a binary rpm. However, there are several development rpms that are needed to successfully compile the httpd RPM. There are a few dependencies that you’ll have to resolve by installing a dozen or so rpms. You may retrieve those necessary rpms from the same place where you downloaded source rpm (step 1).

# cd /usr/src/redhat/SPECS
# rpmbuild -bb httpd.spec

6. Upon successfully rebuilding the Apache, extract the mod_vhost_alias.so file from the binary RPM. We only need to replace the mod_vhost_alias.so located in the /usr/lib/httpd/modules directory, and there is no reason to reinstall binary RPM. To extract a file from the RPM, use the rpm2cpio command below.

# cd /tmp
# rpm2cpio /usr/src/redhat/RPMS/i386/httpd-2.0.x.y.z.legacy.i386.rpm | cpio -d -i
# mv /tmp/usr/lib/httpd/modules/mod_vhost_alias.so /usr/lib/httpd/modules

You may wish to make a back of the mod_vhost_alias.so file before overwriting the original. You’ll need to add SetVirtualDocumentRoot on in the httpd.conf file, and restart the apache.

Did you like this? Share it:

Setting mail header for a foreign language

Filed under :Linux, Networking

Depending on the client’s regional settings and an ability to read foreign language on the client’s computer, emails sent using traditional text/plain mail header may not be readable by foreign receipients. To allow mails to be sent in correct format, the following mail headers must be set in addition to From, CC and BCC mail headers.

MIME-Version: 1.0
Content-Type: text/plain; charset=ks_c_5601-1987
Content-Transfer-Encoding: quoted-printable

The example above uses Korean ks_c_5601-1987 character set, but any language code will work including UTF-8.

Did you like this? Share it:


WEB HOSTING RESOURCES