PHP - Knowledge Base Archives - Hivelocity Hosting https://www.hivelocity.net/kb/tag/php/ Dedicated Servers, Private Cloud & Colocation Thu, 07 Dec 2023 14:08:12 +0000 en-US hourly 1 https://wordpress.org/?v=6.6 How to Install Alternative PHP Cache (APC) on your Server? https://www.hivelocity.net/kb/how-to-install-alternative-php-cache-apc-on-your-server/ https://www.hivelocity.net/kb/how-to-install-alternative-php-cache-apc-on-your-server/#respond Wed, 30 Jan 2013 14:19:04 +0000 https://kb.hivelocity.net/?p=11095 Step a: Login to your server as root.   Step b: Download the APC wget https://pecl.php.net/package/APC   eg : wget https://pecl.php.net/get/APC-3.0.15.tgz   Step c: Extract it over to your server tar -xzf APC-3.0.15.tgz cd APC* Step d: Check the PHP location by running the below command: which php Step e: Create the configuration files using …

How to Install Alternative PHP Cache (APC) on your Server? Read More »

The post How to Install Alternative PHP Cache (APC) on your Server? appeared first on Hivelocity Hosting.

]]>
Step a: Login to your server as root.

 

Step b: Download the APC

wget https://pecl.php.net/package/APC

 

eg : wget https://pecl.php.net/get/APC-3.0.15.tgz

 

Step c: Extract it over to your server

tar -xzf APC-3.0.15.tgz

cd APC*

Step d: Check the PHP location by running the below command:

which php

Step e: Create the configuration files using the below command

Phpize

Stepf: Now the APC need to be compiled over the server :

./configure –enable-apc –enable-apc-mmap –with-apxs –with-php-config=/usr/local/bin/php-config

make

make install

Note : You must install the APC in the php.ini file

Step g: Below command would help you to find the php.ini over the server :

php -i | grep php.ini

Step h : Amend php.ini by adding APC extension, as stated below :

vi /usr/local/Zend/etc/php.ini

Step I : Add the following to the php.ini file

apc.shm_segments=1
apc.optimization=0
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1

Step J : Restart apache

service httpd restart

The post How to Install Alternative PHP Cache (APC) on your Server? appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-to-install-alternative-php-cache-apc-on-your-server/feed/ 0
PHP as an Apache Module https://www.hivelocity.net/kb/php-as-an-apache-module/ https://www.hivelocity.net/kb/php-as-an-apache-module/#respond Wed, 30 Jan 2013 13:57:40 +0000 https://kb.hivelocity.net/?p=11009 When PHP runs as an Apache module, PHP files work under the Apache user/group known as “nobody”. For example, when a PHP file needs to write to another file or create/remove a file, it does so under the name “nobody”. In order to allow “nobody” to do this, you need to set specific permissions on …

PHP as an Apache Module Read More »

The post PHP as an Apache Module appeared first on Hivelocity Hosting.

]]>
When PHP runs as an Apache module, PHP files work under the Apache user/group known as “nobody”. For example, when a PHP file needs to write to another file or create/remove a file, it does so under the name “nobody”. In order to allow “nobody” to do this, you need to set specific permissions on the file/directory, such as 777 – which translates to read/write/execute by user/group/world. This is insecure because you have not only allowed the webserver (Apache) to read/write to the file, you have also allowed everyone else on the server to read/write to the file as well!

Due to the above conditions, when a PHP file creates or uploads a new file under your account, the new file will be owned by the user “nobody”. If you FTP into your account, all files owned by “nobody” will not be available for you to move, rename or delete. In this case the only way to remove the “nobody” owned files would be through a file on the server or to contact support and ask for the file ownership to be changed back to your username.

The post PHP as an Apache Module appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/php-as-an-apache-module/feed/ 0
How will you check and confirm that your server is using suPHP? https://www.hivelocity.net/kb/how-will-you-check-and-confirm-that-your-server-is-using-suphp/ https://www.hivelocity.net/kb/how-will-you-check-and-confirm-that-your-server-is-using-suphp/#respond Wed, 30 Jan 2013 13:56:52 +0000 https://kb.hivelocity.net/?p=11005 It’s very simple to verify this. Have a simple ‘php info’ script. Create a file named ‘phpinfo.php’ under the public_html of your domain Insert the following code: <?php phpinfo(); ?> Access the file in your browser using the link https://yourdomain.com/phpinfo.php At the top section search the line ‘Server API’. If you see’CGI’ then your account …

How will you check and confirm that your server is using suPHP? Read More »

The post How will you check and confirm that your server is using suPHP? appeared first on Hivelocity Hosting.

]]>
It’s very simple to verify this. Have a simple ‘php info’ script.

Create a file named ‘phpinfo.php’ under the public_html of your domain

Insert the following code:

<?php
phpinfo();
?>

Access the file in your browser using the link https://yourdomain.com/phpinfo.php

At the top section search the line ‘Server API’.
If you see’CGI’ then your account is hosted on a server with suPHP.
If it shows ‘apache’ then you are NOT on a suPHP server.

The post How will you check and confirm that your server is using suPHP? appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-will-you-check-and-confirm-that-your-server-is-using-suphp/feed/ 0
How to disable php for a particular user on the server? https://www.hivelocity.net/kb/how-to-disable-php-for-a-particular-user-on-the-server/ https://www.hivelocity.net/kb/how-to-disable-php-for-a-particular-user-on-the-server/#respond Wed, 30 Jan 2013 13:53:20 +0000 https://kb.hivelocity.net/?p=10989 Put the following code in .htaaccess file for that user as: php_flag engine off OR In httpd.conf file,for that particular domain, put the following code in >directory> as <directory> php_admin_flag engine off </directory>

The post How to disable php for a particular user on the server? appeared first on Hivelocity Hosting.

]]>
Put the following code in .htaaccess file for that user as:
php_flag engine off

OR

In httpd.conf file,for that particular domain, put the following code in >directory> as

<directory>
php_admin_flag engine off
</directory>

The post How to disable php for a particular user on the server? appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-to-disable-php-for-a-particular-user-on-the-server/feed/ 0
How can one combine PHP5 with PHP 4 ? https://www.hivelocity.net/kb/how-can-one-combine-php5-with-php-4/ https://www.hivelocity.net/kb/how-can-one-combine-php5-with-php-4/#respond Tue, 29 Jan 2013 14:21:33 +0000 https://kb.hivelocity.net/?p=10902 We have to compile php4 with apache and need to install php5 but do not compile it with apache. Normal configure commands could be used to compile php4 with apache. Now PHP5 Installation. a) You can download the version of pHP5 you would like to install from https://php.net/ REMOVE the “–with-apxs=/usr/local/apache/bin/apxs” from the line. We …

How can one combine PHP5 with PHP 4 ? Read More »

The post How can one combine PHP5 with PHP 4 ? appeared first on Hivelocity Hosting.

]]>
We have to compile php4 with apache and need to install php5 but do not compile it with apache.

Normal configure commands could be used to compile php4 with apache.

Now PHP5 Installation.
a) You can download the version of pHP5 you would like to install from https://php.net/

REMOVE the “–with-apxs=/usr/local/apache/bin/apxs” from the line. We are going to compile CGI version and it may broke the Apache!

b) Make sure you have the following prefixes and suffixes to install to the proper directories – otherwise currently installed php could be broken:
–prefix=/usr/local/php5 –exec-prefix=/usr/local/php5 –program-suffix=5

c) Add the necessary options for proper CGI redirects from Apache:
–enable-force-cgi-redirect –enable-discard-path

The result line will looks like this (please, do not use it – it has no CURL and PostgreSQL support – you better to follow steps below):

#./configure –prefix=/usr/local/php5 –exec-prefix=/usr/local/php5 –program-suffix=5 –with-xml –enable-bcmath –enable-calendar –enable-ftp –with-gd –enable-exif –with-jpeg-dir=/usr –with-png-dir=/usr –with-xpm-dir=/usr/X11R6 –with-imap –with-imap-ssl –with-kerberos –enable-mbstring –with-mbstring=all –enable-mbstr-enc-trans –with-mcrypt –with-mhash –enable-magic-quotes –with-mysql=/usr –with-openssl –enable-discard-path –with-pear –enable-sockets –enable-track-vars –with-ttf –with-freetype-dir=/usr –enable-versioning –with-zlib –with-pspell –with-gettext –enable-inline-optimization –disable-debug –enable-force-cgi-redirect –enable-discard-path

#make
#make install

#cp -f /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
#ln -s /usr/local/Zend/etc/php.ini /usr/local/php5/lib/php.ini

It is recommended to add the following line to the php.ini at the bottom (it is a MUST if you compile php4 instead php5!). Note that this line will broke regular php4. As a common rule – if you are using the same php.ini, do not add this line:

cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode

Now we need to add several lines to Apache

#vi /usr/local/apache/conf/httpd.conf

Scroll down (better use the built-in search) to the “<IfModule mod_dir.c>”
There we should to add index.php5 after index.jp, but before index.php4. Result would looks like this:

<IfModule mod_dir.c>
DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.jp index.php5 iindex.php4 index.php3 index.php index.phtml ndex.htm default.htm default.html home.htm
</IfModule>

This to allow index.php5 as index file.

Continue editing. Find the “AddType application/x-httpd-php .phtml” and after it add this:

Action application/x-httpd-php5 “/cgi-sys/php5”
AddHandler application/x-httpd-php5 .php5

#service httpd configtest
#service httpd stop
#service httpd startssl

The post How can one combine PHP5 with PHP 4 ? appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-can-one-combine-php5-with-php-4/feed/ 0
Php open_basedir Tweak https://www.hivelocity.net/kb/php-open_basedir-tweak/ https://www.hivelocity.net/kb/php-open_basedir-tweak/#respond Sat, 18 Dec 2010 06:41:22 +0000 https://kb.hivelocity.net/?p=2083 Php’s open_basedir protection prevents users from opening files outside of their home directory with php scripts. You can use this function to select which accounts cannot open files outside of their home directory when using php scripts. This is an important security feature as it will prevent users from being able to access system or …

Php open_basedir Tweak Read More »

The post Php open_basedir Tweak appeared first on Hivelocity Hosting.

]]>
Php’s open_basedir protection prevents users from opening files outside of their home directory with php scripts. You can use this function to select which accounts cannot open files outside of their home directory when using php scripts.

This is an important security feature as it will prevent users from being able to access system or other users files with php scripts. It will most importantly stop malicious scripts from being able to access a lot of important information.

  1. To access the Server Setup Menu, click on Server Setup, on the main screen of your WebHost Manager interface. Then, click on Tweak Security.
  2. Click on Configure in the Php’s open_basedir section.
  3. Click on the check box next to Enable php open_basedir Protection to enable Enable php open_basedir Protection.
  4. Click on a check box next to a domain’s name to allow them to open files outside of their home directory with php, if necessary.
  5. Click on Save.

The post Php open_basedir Tweak appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/php-open_basedir-tweak/feed/ 0
Switching PHP Versions in Hsphere https://www.hivelocity.net/kb/switching-php-versions-in-hsphere/ https://www.hivelocity.net/kb/switching-php-versions-in-hsphere/#respond Sun, 05 Dec 2010 06:41:06 +0000 https://kb.hivelocity.net/?p=3120 Watch this tutorial to learn how to switch PHP versions in Hsphere.

The post Switching PHP Versions in Hsphere appeared first on Hivelocity Hosting.

]]>
Watch this tutorial to learn how to switch PHP versions in Hsphere.

The post Switching PHP Versions in Hsphere appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/switching-php-versions-in-hsphere/feed/ 0
Connect to MySQL through PHP https://www.hivelocity.net/kb/connect-to-mysql-through-php/ https://www.hivelocity.net/kb/connect-to-mysql-through-php/#respond Sun, 14 Nov 2010 11:24:26 +0000 https://kb.hivelocity.net/?p=2474 Use the following outline to connect and begin querying the MySQL server from within your PHP scripts. Connect to the MySQL server Use the following statement to connect to the database server. Substitute the username, and password for ones who have created in the MyAdmin interface and have given adequate permissions to this database. MYSQL_CONNECT(‘localhost’,’USERNAME’,’PASSWORD’); …

Connect to MySQL through PHP Read More »

The post Connect to MySQL through PHP appeared first on Hivelocity Hosting.

]]>
Use the following outline to connect and begin querying the MySQL server from within your PHP scripts.

  1. Connect to the MySQL server
    Use the following statement to connect to the database server. Substitute the username, and
    password for ones who have created in the MyAdmin interface and have given adequate
    permissions to this database.
    MYSQL_CONNECT(‘localhost’,’USERNAME’,’PASSWORD’);
  2. Select Your Database
    Use the following statement to select the database you wish to connect to. Make sure you
    substitute the example with your database name.
    @mysql_select_db(“DATABASENAME”);
  3. Executing A Query
    You are now ready to execute your queries. Remember that the databases and users used must be created in the MyAdmin interface in your CP. Most problems that arise with your scripts will be due to incorrect permission settings.

The post Connect to MySQL through PHP appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/connect-to-mysql-through-php/feed/ 0
Forward a website to another url https://www.hivelocity.net/kb/how-do-i-forward-a-website-to-another-url-2/ https://www.hivelocity.net/kb/how-do-i-forward-a-website-to-another-url-2/#respond Sun, 14 Nov 2010 09:40:14 +0000 https://kb.hivelocity.net/?p=2274 There are several ways to accomplish this task, but the simplest to understand is to use php. To do this, you need to create the page that will do the forwarding. This can be any page, as long as it ends in “.php”. If you are trying to redirect a domain, you’d create “index.php” inside …

Forward a website to another url Read More »

The post Forward a website to another url appeared first on Hivelocity Hosting.

]]>
There are several ways to accomplish this task, but the simplest to understand is to use php.

To do this, you need to create the page that will do the forwarding. This can be any page, as long as it ends in “.php”. If you are trying to redirect a domain, you’d create “index.php” inside the public_html directory.

Once you decide which page you will use, then create the file and enter the following text:

header(“Location: https://whereyouwant.com/to/go.html“);
?>
Where https://whereyouwant.com/to/go.html is the location that you want the page to forward to. You can use local values, ie: /page.html, or full urls as in the above example (https://..etc.)

The post Forward a website to another url appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-do-i-forward-a-website-to-another-url-2/feed/ 0
Increase the max upload filesize in apache/php https://www.hivelocity.net/kb/how-do-i-increase-the-max-upload-filesize-in-apachephp-2/ https://www.hivelocity.net/kb/how-do-i-increase-the-max-upload-filesize-in-apachephp-2/#respond Sun, 14 Nov 2010 09:39:32 +0000 https://kb.hivelocity.net/?p=2270 edit: /usr/local/lib/php.ini Search for ; Maximum allowed size for uploaded files. upload_max_filesize = 2M Change the 2M to whatever new value you want, then restart apache.

The post Increase the max upload filesize in apache/php appeared first on Hivelocity Hosting.

]]>
edit:
/usr/local/lib/php.ini

Search for

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Change the 2M to whatever new value you want, then restart apache.

The post Increase the max upload filesize in apache/php appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/how-do-i-increase-the-max-upload-filesize-in-apachephp-2/feed/ 0
Recompile PHP on a Direct Admin control panel server https://www.hivelocity.net/kb/recompile-php-on-a-direct-admin-control-panel-server/ https://www.hivelocity.net/kb/recompile-php-on-a-direct-admin-control-panel-server/#respond Sun, 14 Nov 2010 09:36:10 +0000 https://kb.hivelocity.net/?p=2259 SSH to server and then run the following commands. cd /usr/local/directadmin/customapache ./build clean ./build update ./build php

The post Recompile PHP on a Direct Admin control panel server appeared first on Hivelocity Hosting.

]]>
SSH to server and then run the following commands.

cd /usr/local/directadmin/customapache
./build clean
./build update
./build php

The post Recompile PHP on a Direct Admin control panel server appeared first on Hivelocity Hosting.

]]>
https://www.hivelocity.net/kb/recompile-php-on-a-direct-admin-control-panel-server/feed/ 0