Server and Network Monitoring with iPhone
February 25, 2010 – 6:53 pm | No Comment

What is a Unix sysadmin doing with an iPhone, you ask? It was a birthday present, if that’s all right with you. I know, I should have gotten something odd with a beta version of …

Read the full story »
Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands and Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands and Shells, Web Design, WordPress

Web Hosting Providers and php.ini

Submitted by admin on October 9, 2009 – 4:07 pmNo Comment
Web Hosting Providers and php.ini

The php.ini is the primary configuration file for the PHP – a popular scripting language used for Web development. Most Web hosting providers offer preinstalled PHP on their servers. However, not many hosting providers explain where to find and how to use the php.ini file. The following is a quick how-to designed for Linux-based hosting environments.

To follow the instructions below you will need to connect to your Web hosting provider via SSH. Most hosting providers offer access to a Unix shell. In some cases, however, you need to activate Unix shell access before you can use it. Contact your provider’s tech support for instruction on how to do this. If you are connecting from a Windows PC, you can use the free PuTTY terminal client to connect to your hosting provider.

When you sign up for a Web hosting plan, the root folder of your Web server is likely to be ${HOME}/public_html or ${HOME}/www, where $HOME is your home directory and “www” is usually a soft link to “public_html”. If your $HOME variable is not set (if entering “echo $HOME” produces no result – unlikely but possible), you can try the following command to determine your home directory:

grep `whoami | awk '{print $1}'` /etc/passwd | awk -F':' '{print $6}'

The default php.ini file can usually be found in /usr/local/lib/php.ini. If it is not there, you can search for it (usually in /usr) by running the following command:

find /usr -type f -name "php.ini"

Once you found the file, you need to copy it to your Web server’s root folder:

cp -p /usr/local/lib/php.ini ${HOME}/public_html/

Certain Web applications that use PHP require a copy of php.ini in every application subfolder containing *.php files. For example, many WordPress plugins would not work correctly unless there is a copy of php.ini in every plugin directory. As you may imagine, with so many copies of php.ini, making changes to this file can get very tedious. A better solution is to place a link from every directory to the php.ini located in the Web server’s home folder.

Below is the script that will analyze your Web server’s home directory, find every subfolder with *.php files, determine which ones do not already have a php.ini file or link, and create a link to the main php.ini file that you copied earlier. This way you will only need to modify the single php.ini file located in the Web server’s home folder.

#!/bin/ksh
 
username=$(whoami | awk '{print $1}')
homedir=$(grep $username /etc/passwd | awk -F':' '{print $6}')
webhome="${homedir}/public_html"
 
if [ ! -r "${webhome}/php.ini" ]
then
        if [ -f /usr/local/lib/php.ini ]
        then
                cp -p /usr/local/lib/php.ini ${webhome}/php.ini
        else
                echo "File php.ini not found"
                exit 1
        fi
fi
 
 
find "$webhome" -type d | while read dir
do
        if [ `ls -als "$dir" | grep -c ".php"` -gt 0 ] && [ `ls "$dir" | grep -c "php.ini"` -eq 0 ]
        then
                echo "Linking ${dir}/php.ini"
                ln -s "${webhome}/php.ini" "${dir}/php.ini"
        fi
done

Download the default php.ini
Download the above script. Before using, make the script executable: chown +x link_phpini.ksh

Popularity: 4% [?]

Related posts

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.