PHP Parse Error: syntax error, unexpected $end

0

In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:

But more commonly, the error is often caused by the use of Short Open tags in PHP. To use short open tags, it must be enabled in PHP.INI.

short_open_tag = On

Common PHP Compilation errors

0

Some PHP compilation errors you may encounter while configuring PHP and their fixes:

checking for BZip2 support… yes
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution

Fix:
yum install bzip2-devel

===================================

checking for cURL support… yes
checking if we should use cURL for url streams… no
checking for cURL in default path… not found
configure: error: Please reinstall the libcurl distribution –
easy.h should be in /include/curl/

Fix:
yum install curl-devel

==================================

checking for curl_multi_strerror in -lcurl… yes
checking for QDBM support… no
checking for GDBM support… no
checking for NDBM support… no
configure: error: DBA: Could not find necessary header file(s).

Fix:
yum install db4-devel

===================================

checking for fabsf… yes
checking for floorf… yes
configure: error: jpeglib.h not found.

checking for fabsf… yes
checking for floorf… yes
checking for jpeg_read_header in -ljpeg… yes
configure: error: png.h not found.

Fix:
yum install libpng-devel

=====================================

checking for png_write_image in -lpng… yes
If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.
Fix: Reconfigure your PHP with the following option.
–with-xpm-dir=/usr

===================================

checking for png_write_image in -lpng… yes
configure: error: libXpm.(a|so) not found.

Fix:
yum install libXpm-devel

===================================

checking for bind_textdomain_codeset in -lc… yes
checking for GNU MP support… yes
configure: error: Unable to locate gmp.h

Fix:
yum install gmp-devel

==================================

checking for utf8_mime2text signature… new
checking for U8T_DECOMPOSE…
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Fix:
yum install libc-client-devel

================================

checking for LDAP support… yes, shared
checking for LDAP Cyrus SASL support… yes
configure: error: Cannot find ldap.h

Fix:
yum install openldap-devel

=================================

checking for mysql_set_character_set in -lmysqlclient… yes
checking for mysql_stmt_next_result in -lmysqlclient… no
checking for Oracle Database OCI8 support… no
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Fix:
yum install unixODBC-devel

=================================

checking for PostgreSQL support for PDO… yes, shared
checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
yum install postgresql-devel

==================================

checking for sqlite 3 support for PDO… yes, shared
checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext
checking for sqlite3 files in default path… not found
configure: error: Please reinstall the sqlite3 distribution

Fix:
yum install sqlite-devel

==================================

checking for utsname.domainname… yes
checking for PSPELL support… yes
configure: error: Cannot find pspell

Fix:
yum install aspell-devel

================================

checking whether to enable UCD SNMP hack… yes
checking for default_store.h… no

checking for kstat_read in -lkstat… no
checking for snmp_parse_oid in -lsnmp… no
checking for init_snmp in -lsnmp… no
configure: error: SNMP sanity check failed. Please check config.log for more information.

Fix:
yum install net-snmp-devel

================================

checking whether to enable XMLWriter support… yes, shared
checking for xml2-config path… (cached) /usr/bin/xml2-config
checking whether libxml build works… (cached) yes
checking for XSL support… yes, shared
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
yum install libxslt-devel

===============================

configure: error: xml2-config not found. Please check your libxml2 installation.

Fix:
yum install libxml2-devel

===============================

checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

Fix:
yum install pcre-devel

===============================

libtool: link: cannot find the library `/usr/lib/libidn.la’ or unhandled argument `/usr/lib/libidn.la’
make: *** [sapi/cgi/php-cgi] Error 1

Fix:
cd /usr/src/
wget http://ftp.gnu.org/gnu/libidn/libidn-1.26.tar.gz
tar -zvxf libidn-1.26.tar.gz
cd libidn-1.26
./configure
make
make install
ln -s /usr/local/lib/libidn.la /usr/lib/libidn.la

===============================

libtool: link: `/usr/lib/libxml2.la’ is not a valid libtool archive
make: *** [ext/xsl/xsl.la] Error 1

Fix:
cd /usr/src/
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
tar -zvxf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
./configure –prefix=/usr
make
make install

================================
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.

Fix:

yum install t1lib-devel.x86_64
==================================
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Fix:

yum install libmcrypt-devel.x86_64
=================================
configure: error: Cannot find libtidy

Fix:
yum install libtidy libtidy-devel

Error while loading shared libraries: /usr/lib/libstdc++.so.6

0

I have faced an error while checking php version

Error while loading shared libraries: /usr/lib/libstdc++.so.6: requires glibc 2.5 or later dynamic linker

Solution;-

cd /usr/lib/

ls -la libst*;

#then remove symbolic link
rm libstdc++.so.6

#then recreate symbolic link for OLD file libstdc++.so.6.0.3 because libstdc++.so.6.0.8 not working

ln -s libstdc++.so.6.0.3 /usr/lib/libstdc++.so.6

#check what you done
ls -la libst*;

How to install Custom PHP Version for suphp handler domains.

33

How to install Custom PHP Version for suphp handler domains.

# cd /usr/src
# wget http://us.php.net/get/php-5.4.17.tar.gz
# tar -zvxf php-5.4.17.tar.gz
# cd php-5.4.17

To check the current PHP configuration option

# php -i | grep configure

Here I am using prefix as /usr/local/php-5.4.17

[ #./configure –prefix=/usr/local/php-5.4.17 –enable-cli –enable-cgi –with-curl –as per your requirements.

#make
#make install

Check the PHP Version

-bash-4.1# /usr/local/php-5.4.17/bin/php -v
PHP 5.4.17 (cli) (built: Jul 19 2013 00:45:34)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd.
-bash-4.1#

Copy the main php.ini on the Custom php location, here it is /usr/local/php-5.4.17/lib

Check the current configuration file for Custom php.ini

-bash-4.1# /usr/local/php-5.4.17/bin/php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php-5.4.17/lib
Loaded Configuration File => /usr/local/php-5.4.17/lib/php.ini
-bash-4.1#

Add the required PHP modules on extension directory. Here I have downloaded the ionCube and copy the .so module on ***20100525 directory

[IONLoader]
zend_extension=/usr/local/php-5.4.17/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so

# vim /opt/suphp/etc/suphp.conf

[handlers]
application/x-httpd-php5.4=”php:/usr/local/php-5.4.17/bin/php-cgi”

# /usr/local/apache/conf/includes/pre_main_2.conf


Allow from All

### check the domain document root and set info page.
suPHP_AddHandler application/x-httpd-php5.4
AddType application/x-httpd-php5.4 .php

Also add the handler in the domain .htacess file.

/etc/rc.d/init.d/httpd configtest
/etc/rc.d/init.d/httpd restart

———————————>

Install Suhosin PHP 5 Protection Security Patch

1

WordPress and many other open source application developers asks users to protect PHP apps using Suhosin patch to get protection from the full exploit. Suhosin is an advanced protection system for PHP installations. It was designed to protect your servers from various attacks. How do I install Suhosin under RHEL / CentOS / Fedora Linux?
A. Suhosin was designed to protect your servers against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself including wordpress and many other open source php based apps.

Install Suhosin as extension

Download latest version of Suhosin, enter:
# cd /opt
# wget http://download.suhosin.org/suhosin-0.9.27.tgz
Make sure you have php-devel installed:
# yum install php-devel
Compile Suhosin under PHP 5 and RHEL / CentOS Linux
Type the following commands:
# cd suhosin-0.9.27
# phpize
#./configure
# make
# make install
Configure Suhosin
Type the following command to create Suhosin configuration file:
# echo ‘extension=suhosin.so’ > /etc/php.d/suhosin.ini

Restart web server
# service httpd restart
If you are using lighttpd, enter:
# service lighttpd restart

Verify Suhosin installation
$ php -v
Sample output:
PHP 5.1.6 (cli) (built: Jun 12 2008 05:02:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

You can find more information by running phpinfo():
=================================================================>

How to Install Memcache into cPanel Server.

0

Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

Make the Sources Folder
mkdir ~/memcache

Compile and Install LibEvent

cd ~/memcache
wget http://www.monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar xvfz libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure
make
make install

Compile and Install Memcache

cd ~/memcache
wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xvfz memcached-1.2.6.tar.gz
cd memcached-1.2.6
./configure –with-lib-event=/usr/local/
make
make install

Starting Memcache
memcached

If you get the following error then you may beed to register libevent:
error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

Register LibEvent

vi /etc/ld.so.conf.d/libevent-i386.conf
Open above file and put the line /usr/local/lib/ and save the file and fire below command.
ldconfig

Installing PHP Memcache

cd ~/memcache
wget http://pecl.php.net/get/memcache-3.0.3.tgz
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
phpize
./configure
make
make install

Add extension on php.ini

vi /usr/local/lib/php.ini
extension=memcache.so

Then restart the Apache service.
service httpd restart

=============================================>
Reference : http://php.net/manual/en/book.memcache.php
Reference : http://www.memcached.org/

How to Install & compile Zend Guard Loader

2

The Zend Guard Loader runs PHP scripts that are encoded with Zend Guard. The Zend Guard Loader is a PHP extension that runs outputs created by Zend Guard, which provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line.

The Guard Loader extension must be installed on each Web server that runs files that were encoded with, or use, Zend Guard licenses.
Note:

You can also use the Zend Optimizer that also includes the Guard Loader extension for code written in PHP 5.2. The Zend Optimizer is available as a free download from PHP Web Application Server – PHP Development tools – PHP Training – Zend.com.

The Zend Guard Loader translates encoded files to a format that can be parsed by the Zend Engine. This runtime process uses the Zend engine as a trigger to start the Zend Guard Loader component. Zend Guard is a separate product available from Zend that provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line. To view the API, click Zend Guard Loader.

To install it you need to follow the below mentioned steps:

# wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/lib/php

Now after that open php.ini file and put a

zend_optimizer.optimization_level=15
zend_extension=/usr/local/lib/php/ZendGuardLoader.so
restart apache

php -v to check it will show as

# php -v
PHP 5.3.15 (cgi-fcgi) (built: Sep 17 2012 04:07:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

================================>

PHP Fatal Error: Out Of Memory

3

PHP Fatal Error: Out Of Memory

PHP Fatal error: Out of memory (allocated 45236595) (tried to allocate 74521 bytes) in /home/xxxxx/public_html/xyz/admin.php(154) on line 40

Solution is to increase the memory allocated for PHP.

1. Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini

Open the php.ini file in a text editor and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.

2. In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after
ini_set(’memory_limit’, ‘12M’);

3. You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M

4. Or else, Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define(‘WP_MEMORY_LIMIT’, ’32M’);
————————————————————————–>

SuExec server permission issue

2

SuExec server permission issue?

After enabling SuExec on server most users getting “500 Internal Server Error” at that time refer following steps.

1st) Correct cPanel users files/directories ownership.

——

for i in `cat /etc/trueuserdomains | awk ‘{print $2}’`
do
chown $i.$i /home/$i -R;
chown $i.mail /home/$i/etc -R;
chown $i.nobody /home/$i/public_html;
done;

—–

2nd) Correct permission for files and directories for cPanel users from shell but make sure that you logged in as root user and running following command in /home partition.

—–

find . -type d -perm 777 -exec chmod 755 {} \;

find . -type f -perm 644 -exec chmod 755 {} \;
——————————————————-

Cannot load mysql extension. Please check your PHP configuration

26

Cannot load mysql extension. Please check your PHP configuration

How do I fix this problem under CentOS / RHEL / Fedora Linux Apache web server?

You need to install php-mysql which is a module for PHP applications that use MySQL databases. And you may also need to install the following:

php-mysql : Module for PHP applications that use MySQL databases
php-gd : A module for PHP applications for using the gd graphics library
php-mbstring : A module for PHP applications which need multi-byte string handling
php-mcrypt : Standard PHP module provides mcrypt library support

Type the following command to fix your issue:
# yum -y install php-mysql
# service httpd restart

No need to edit /etc/php.ini as php-mysql package comes pre configured with /etc/php.d/mysql.ini file:
# cat /etc/php.d/mysql.ini

Sample outputs:
; Enable mysql extension module
extension=mysql.so
Optional Modules

To install other modules type:
# yum -y install php-mbstring php-mcrypt php-gd
# service httpd restart

==========================================================