Laravel Project, 500 internal server error - php

I developed a simple application in laravel (5.6) everything works fine on my PC (windows 10/ Xamp / PHP 7.1). but when i upload the same project to a VPS running Cent OS it gives
with PHP 5.6 (which is expected)
Parse error: syntax error, unexpected '?' in /home/clarionit/public_html/ambience/c/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233
with PHP 7.0 / 7.1 / 7.2
500, Internal server error.
What I have done so far?
Permissions for all files and folders are set to 777 (to see if that is a problem)
Replacing index.php code with something simpler like phpinfo() works perfectly.
Ask for any more information needed, Please tell me what can be causing the 500, internal server error.

Laravel 5.6 requirement should be installed in system
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
Once run these commands, I hope your problem will resolve.
rm -rf vendor
rm -rf storage/framework/cache/*
rm -rf storage/framework/session/*
rm -rf storage/framework/views/*
rm composer.lock
composer clear-cache
composer install

Related

Mcrypt Extention required error in Bitnami MAMP stack

I am using Bitnami MAMP Stack 5.6.34. And installed it as root user so it loads at port 80. I am trying to install laravel 4.2 using composer and it shows that:
Mcrypt PHP extension required error.
and also while I try to use
php artisan
it does not work. Mcrypt is installed as it shows Enabled while I output phpinfo() function. But it still does not show up when I try using
php -m | grep mcrypt
I have modified php.ini file as follows:
mcrypt.algorithms_dir= /Applications/mampstack/common/lib/libmcrypt
mcrypt.modes_dir= /Applications/mampstack/common/lib/libmcrypt
But it does not work and still shows:
Mcrypt PHP extension required error.
But when I cd into mampstack and then use
sudo ./use_mampstack
then in the terminal I don't get any error while using composer install and can also use php artisan command as it finds that Mcrypt is enabled.
How can I get rid the Mcrypt error and load it with installed php
Bitnami Engineer here. I just installed Laravel in a fresh Bitnami installation in Mac OS X. These are the steps I followed
cd installdir/frameworks
curl -LO "https://github.com/laravel/laravel/archive/v4.2.11.zip"
unzip v4.2.11.zip
mv laravel-4.2.11 laravel
cd laravel
composer install
php artisan --version
Then, configure Apache using the similar config files (httpd-prefix.conf and httpd-app.conf) than the other frameworks or the ones at installdir/docs/demo. You will only need to modify the different paths in those files and include the httpd-prefix.conf file in the installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file. Restart Apache at the end to load this configuration.
I hope this helps

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

Having issue in installing mongoDB PHP driver

I am very new to mongoDB. I have downloaded the setup for mongoDB but before that I have to install the mongoDB PHP driver.
When I downloaded the driver I got these instruction in the documentation:
Installation
To install:
$ phpize
$ ./configure
$ make
$ sudo make install
When I run this command phpize on cmd then it gives me this error
'phpize' is not recognized as an internal or external command.
I am using:
MongoDB version 1.0
PHP version 5.5
Windows 7
I was having a similar issue a week ago. I struggled a lot and finally found that I had downloaded the wrong DLL file. (My system is 64-bit, so I downloaded the DLL for 64-bit. However, phpInfo() shows that my php is 32-bit. So, I downloaded the 32-bit DLL file and it worked!)
Have a look at the following tutorial if you still have any queries:
https://www.youtube.com/watch?v=HBKNKl5OG_8&t=356s
I hope that helps!

Error installing Laravel 4 with composer

When I try to install Laravel 4 via Composer, I get the following message in Terminal
Mcrypt PHP extension required. Script php artisan optimize handling
the post-install-cmd event returned with an error
The PHP version on my computer is 5.5.3 and when I run phpinfo it shows that mcrypt is enabled. When I run the which php command in Terminal it shows
/usr/bin/php
I therefore extended the $PATH with .bash_profile.
export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH
Unfortunately, the which php command still shows /usr/bin/php after extending $PATH. And as a result the error is still there.
So I am out of ideas on how to solve this issue. Does anyone have an idea? Thanks!
There is difference between the MAMP PHP version and you "Terminal" PHP version. Therefore are you probably setting up the export path.
When you are changing the export path you have to restart your terminal before it will take effect on your computer.
I am not sure of this but when your error is appearing and older version of Laravel will be installed.
What do you get when you execute: php -v in your terminal?

Class Phar not found in VPS

I have purchased a VPS in Dreamhost. Now Im trying to run php composer.phar install but it says:
Fatal error: Class 'Phar' not found in
/home/john/mysite.com/composer.phar on line 13
Since I have found out that I have these directories:
/usr/local/php /usr/local/php53 /usr/local/php54
and, for example, in /usr/local/php53/bin/ I have this:
phar phar.phar php php-cgi php-config phpize
,how can I run php composer.phar install without errors?
If you need more information about content in folders I will give it of course.
This works for me:
php -d extension=phar.so composer.phar [... your command ...]
This includes the phar extension for the current runtime. Works for shared / VPC servers.
It looks like you might not have the phar extension installed or configured correctly. It might be worth checking the output of a call to phpinfo().

Categories