Archive for the ‘php’ category

Install php and fastcgi on CentOS 7

April 26th, 2017

This assumes you already installed CentOS 7.

to get fastcgi and php do the following:

yum install epel-release  
yum install openssh-clients rsync net-tools mc iptraf htop nc ifconfig wget
yum install php-xcache httpd php-mbstring php-bcmath php-mysql php-xml php-xmlrpc php-pecl-memcached php-pecl-memcache php  php-cli php-fpm  mod_fcgid

vi /etc/httpd/conf.d/php.conf

# line 5: change like follows

#    SetHandler application/x-httpd-php
    SetHandler "proxy:fcgi://127.0.0.1:9000" 



systemctl start php-fpm
systemctl enable php-fpm
systemctl restart httpd
systemctl enable  httpd
if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

PHP/HTTP max upload error

November 18th, 2011

There are several reasons that you cannot upload a file with a script. The following are 2 possible reasons.

The first, simple enough, is the file size is too large. To fix this just modify the “upload_max_filesize” modifier in php.ini. To determine the location of the php.ini being used by that domain quickly create a phpinfo() page. (simple page with ) this will display the information.

note: remove this file afterwards as it gives information on your server and can be considered a security risk

The other possible reason, and you need to look at your error logs to verify this is if you are getting a similar error message to this:

 mod_fcgid: HTTP request length 138361 (so far) exceeds MaxRequestLen (131072), referer:

or something similar.

This indicates that the apache configuration needs a little tweaking.

do a quick search for the file: fcgid.conf
modify it by adding the following line

FcgidMaxRequestLen 200000000

This sets the limit to 200MB.
Example file would look like:

<IfModule mod_fcgid.c>

<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>

  FcgidIPCDir /var/run/mod_fcgid/sock
  FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm

  FcgidIdleTimeout 40
  FcgidProcessLifeTime 30
  FcgidMaxProcesses 20
  FcgidMaxProcessesPerClass 8
  FcgidMinProcessesPerClass 0
  FcgidMaxRequestLen 200000000
  FcgidConnectTimeout 30
  FcgidIOTimeout 45
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 10

</IfModule>

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

PHP – Header format to send html pages via mail function

May 11th, 2011

This is the following format to send an html mail using the mail function in php. It goes in the header.

 $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers  .= "From: $from\r\n"; 

Notice the “\r\n” at the end of each line. THAT MUST be there

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

PHP – Turn safe_mode off with .htaccess or php.ini

November 29th, 2010

Sometimes you need to turn off safe mode on PHP for a page to load properly. There are several options to allow this and they are to

Turn off safe mode for a domain with the .htaccess file:

Put this line inside .htaccess file to turn it off:
php_value safe_mode off

if the above does not work try: 

php_flag safe_mode off

also try substituting the "off" word with: 0

Eg: php_value safe_mode 1

The other option is to create/modify a php.ini file in the cgi-bin folder and have the line

safe_mode = off

Or if you wish to turn off safe mode for the entire server

modify the /etc/php.ini and set safe_mode = On to safe_mode = off.
if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz

Plesk – phpMyAdmin file not found 8443/domains/databases/phpMyAdmin/export.php

June 24th, 2010

If you try and export a DB in plesk and get the error message:

File not Found 
can’t find the file at https://xx.xx.xx.xx:8443/domains/databases/phpMyAdmin/export.php.

Then chances are that the memory_limit for php is too low for the operation. The simple solution is to SSH into the server and do the following:

Go to : /usr/local/psa/admin/conf/
Edit : php.ini
and increase memory_limit, a good level is 512MB 
restart plesk control panel (/etc/init.d/psa stop/start)

Once you restart the plesk control panel test the export once more. It should now work

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d
BTC: 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz