Tag: PHP

Swapping between php versions when using suPHP and CLI with custombuild

by admin on Sep.07, 2009, under DirectAdmin

If you have both suPHP and CLI installed on your system, but don’t feel like renaming all of your file.php to file.php4 (for example), there is another means to chose between php versions, without requiring to touch your php files.
To force php files to use CLI (on the assumption your default php version uses suPHP) create an .htaccess file in your public_html directory, with the following:

<FilesMatch "\.php$">
AddHandler application/x-httpd-php .php
</FilesMatch>

To force php files to use suPHP (on the assumption your default php version uses CLI) use the following:

<FilesMatch "\.php$">
AddHandler x-httpd-php5 .php
</FilesMatch>

This last one is on the assumption that php 5 is suPHP and CLI is php4. If php4 was suPHP, then you’d use x-httpd-php4 to force .php files to use suPHP with php 4.

Leave a Comment :, , , , more...

Allow php scripts to work under ~username when using suPhp (custombuild)

by admin on Sep.07, 2009, under DirectAdmin

By default, suPhp is compiled in "paranoid" mode. This means that the settings in the user httpd.conf files:

suPHP_UserGroup username username

will require all php files to be owned by username or suPhp will throw a "500 Internal Server Error".
This does not apply to domains, when used normally, because each domain has it’s own VirtualHost with the suPHP_UserGroup inside it using the correct settings.
The ~username (UserDir) method will fail in paranoid mode, because there is not a virtualhost for each ~username path, and no suPHP_UserGroup settings for each user, hence you get the 500 error.
The solution to this is to compile suPhp in "owner" mode instead of "paranoid" mode.
To do that, run these commands.

cd /usr/local/directadmin/custombuild
mkdir -p custom/suphp
cp -fp configure/suphp/configure.suphp custom/suphp/configure.suphp
perl -pi -e ‘s/paranoid/owner/’ custom/suphp/configure.suphp
./build clean
./build suphp
cd /usr/local/directadmin/data/templates/custom
cp -f ../virtual_host* .
perl -pi -e ‘s/suPHP_UserGroup/#suPHP_UserGroup/’ virtual_host*.conf
perl -pi -e ‘s/suPHP_UserGroup/#suPHP_UserGroup/’ /etc/httpd/conf/httpd.conf
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

Which will change all references of suPHP_UserGroup to #suPHP_UserGroup, basically, just commenting them out.

Leave a Comment :, , , , more...

I want apache 2.0, php 5 and mysql 5

by admin on Sep.07, 2009, under DirectAdmin

DirectAdmin essentially will work with any version of the software you want (within reason). You can use these newer versions of the software should you with to have them.
*** For Apache 2.2 and php 5.x, we have a new custombuild script available:
http://files.directadmin.com/services/custombuild/1.1. It will install both apache 2.2 and php 5 automatically for you. It also contains code for installing mysql 5. The custombuild script is consider the more recent way to install apache 2, php 5 and mysql 5. The rest of the guide will still work, but it’s more time consuming.


To convert apache 1.3 to apache 2.0, use this guide:
directadmin.com/features.php?id=441

For php 5, use this guide (after you are running the apache version you want to have):
help.directadmin.com/item.php?id=135

Regarding MySQL 5.0, you must first decide if you are eligible for the version change. If you are running MySQL 4.1.x or higher, then there won’t be any issues. If you are running MySQL 4.0.x or lower, then you have to take note of the following:
There passwords and table format changes between 4.0 and 4.1. Updating tables to the 4.1 format is not too difficult after the update is done:

mysql_fix_privilege_tables –user=da_admin –password=`cat /usr/local/directadmin/conf/mysql.conf | grep passwd |cut -d= -f2`

**However**, the password format cannot be converted to the new password format in 4.1. You have 2 choices:
1) After updating, go through all MySQL accounts and resave their passwords. You will need to know their plaintext password to do this. This is ideal so that you are using the latest formats and do not need to worry about compatibility issues with future releases.
2) Retain the old password formats and tell the new version of mysql to use those old formats by adding:

[mysqld]
old_passwords

into your /etc/my.cnf file, then restart mysqld. You will need to create this file.
This 2nd option is good to save time, but if you ever need to transfer the accounts to a new server already running MySQL 4.1 or higher, you will need to resave all mysqld password for that transferred account. The MySQL server should have all passwords in the same format.. either the new one, or the old one. If there are already account in the new format, you need to resave the passwords to it.
Related guide: directadmin.com/features.php?id=466
Once you’ve decided if the update is for you, use these guides to do it:
FreeBSD/Debian:
help.directadmin.com/item.php?id=106
You will need to get the binaries for your particular OS version. If you cannot file them on files.directadmin.com/services, then go to dev.mysql.com and download the binaries for your system. We do not have any special compile options, and we use all stock binaries from dev.mysql.com whenever possible. **Note** that the guide there contains freebsd binaries. Debian binaries would have to be downloaded if you use Debian. The same instructions apply.
Redhat/Fedora/CentOS (anything with rpms):
Conversion with rpms is quite easy (note the above notices about moving from 4.0 to 4.1 or higher still apply).
Download the 4 MySQL rpms that you want to use, either from files.directadmin.com or from dev.mysql.com. You’ll need the server, client, shared and devel rpms. You must not have any mismatched versions. We recommend generic i386 rpms. If you have 64-bit system, then you’ll need binaries specific to your system (dev.mysql.com has everything you’ll need)
Use wget to download all 4 rpms, then use "rpm -Uvh file.rpm" to update/install them, for example:

mkdir mysql
cd mysql
wget http://files.directadmin.com/services/all/mysql/MySQL-client-5.0.37-0.i386.rpm
wget http://files.directadmin.com/services/all/mysql/MySQL-devel-5.0.37-0.i386.rpm
wget http://files.directadmin.com/services/all/mysql/MySQL-server-5.0.37-0.i386.rpm
wget http://files.directadmin.com/services/all/mysql/MySQL-shared-5.0.37-0.i386.rpm
rpm -Uvh MySQL-*-5.0.37-0.i386.rpm
/sbin/service mysqld restart

Again, keep in mind any changes you may need to do to your database to make this version work.
If you have a clean DirectAdmin install without any databases on it yet and you wish to install the new version, it would likely be easier to use this guide to move cleanly to the version you want: help.directadmin.com/item.php?id=96. It will install all data and passwords after deleting the previous data (hence, youll need a new install first because any databases are going to be lost). For the guide, you’d replace the 4.0 rpms used in the example and simply download the 5.0.x version mentioned above.
It’s also recommended you do a full php recompile to load in MySQL’s current version of the client libraries. Hence, if you are going to be updating php anyway, do MySQL first.

Leave a Comment :, , , more...

How to update to php 5

by admin on Sep.07, 2009, under DirectAdmin

Note: If you want the latest version of php and apache, it’s recommended you use custombuild:
http://files.directadmin.com/services/custombuild/1.1
The following guide is only to be used if if you still want to use the old apache versions… basically, only if you still need FrontPage.


To update to php5, the build script will still work. All that you need to do is swap out the version, compile normally and make a few modifications to your /etc/httpd/conf/httpd.conf file.
1) download the php-5.2.4.tar.gz from php.net into your customapache directory:

cd /usr/local/directadmin/customapache
wget http://files.directadmin.com/services/customapache/php-5.2.4.tar.gz

2) change your build script for the new version:

nano build

change: PHP_VER=4.4.4
to: PHP_VER=5.2.4
3) build php normally:

./build clean
./build php n

If you’re using apache 2.x, use

./build clean
./build php_ap2 n

instead.
4) edit /etc/httpd/conf/httpd.conf
Remove any referce of:

LoadModule php4_module modules/libphp4.so

and make sure they’re replaced with:

LoadModule php5_module modules/libphp5.so

Remove any reference of:

AddModule mod_php4.c

and replace with:

AddModule mod_php5.c

5) find this piece of code:

<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php3 index.phtml index.cgi
</IfModule>

replace with:

<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php5 index.php3 index.phtml index.cgi
</IfModule>

Find this:

<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

(it might have AddHandler instead of AddType)
replace with:

<IfModule mod_php5.c>
AddHandler application/x-httpd-php .inc .php .php5 .php4 .php3 .phtml
AddHandler application/x-httpd-php-source .phps
</IfModule>

Then restart apache.
If you get the following error while compiling php:

checking whether to enable LIBXML support… yes
checking libxml2 install dir… no
checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2
installation.
*** There was an error while trying to configure php. Check the configure.php file

Then edit the configure.php file (or configure.php_ap2 if you’re using apache 2), and change:

–with-xml \

to:

–disable-libxml \
–disable-dom \
–disable-xml \
–disable-simplexml \
–disable-xmlreader \
–disable-xmlwriter \

or else install the missing rpms/packages for xml. (libxml2-dev and libxml2-utils on debian). Redhats:

yum -y install libxml2-devel libxslt-devel

FreeBSD:

pkg_add -r libxml2
pkg_add -r libxslt

On debian systems if using apt-get to install libxml2-dev and libxml2-utils doesn’t work, then install from source:

wget http://files.directadmin.com/services/customapache/libxml2-2.6.30.tar.gz
tar xvzf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure
make && make install

then recompile php as usual.

Leave a Comment :, , , , , more...

Fatal error: Allowed memory size of 123456 bytes exhausted (tried to allocate 234567 bytes) in /path/file.php

by admin on Sep.07, 2009, under DirectAdmin

Php is setup is to limit memory usage per process. If you require more, this limit can be increased.
Edit

/usr/local/lib/php.ini

and set:

memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

to a higher value, like 20M. Save, exit, then restart apache.

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Kontak

Budhi Indah A 31
Cimindi Cimahi 40514
West Java
Indonesia

Phone/SMS :
Info/Bantuan : 62-8158-6270622
Billing/konfirmasi : 62-8888-763551

Self Advertise


My site is worth $7548.2.
How much is yours worth?