SocketException Permission denied - CakePHP 2.3 - php

I receive that error when try send e-mail with CakePHP 2.3.0.
My Cloud configuration is:
PHP 5.4
Apache 2.2
MySQL 5.5
CakePHP 2.3.0
Sorry about my english.
2013-03-06 09:15:05 Error: [SocketException] Permission denied
Request URL: /notifications/sendContact
Stack Trace:
#0 /var/www/html/site/lib/Cake/Network/Email/SmtpTransport.php(96): CakeSocket->connect()
#1 /var/www/html/site/lib/Cake/Network/Email/SmtpTransport.php(60): SmtpTransport->_connect()
#2 /var/www/html/site/lib/Cake/Network/Email/CakeEmail.php(1065): SmtpTransport->send(Object(CakeEmail))
#3 /var/www/html/site/app/Controller/NotificationsController.php(41): CakeEmail->send()
#4 [internal function]: NotificationsController->sendContact()
#5 /var/www/html/site/lib/Cake/Controller/Controller.php(485): ReflectionMethod->invokeArgs(Object(NotificationsController), Array)
#6 /var/www/html/site/lib/Cake/Routing/Dispatcher.php(186): Controller->invokeAction(Object(CakeRequest))
#7 /var/www/html/site/lib/Cake/Routing/Dispatcher.php(161): Dispatcher->_invoke(Object(NotificationsController), Object(CakeRequest), Object(CakeResponse))
#8 /var/www/html/site/app/webroot/index.php(102): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#9 {main}
2013-03-06 09:15:05 Error: Fatal Error (256): [CakeException] Unknown status code
#0 /var/www/html/site/lib/Cake/Error/ExceptionRenderer.php(212): CakeResponse->statusCode(13)
#1 [internal function]: ExceptionRenderer->error400(Object(SocketException))
#2 /var/www/html/site/lib/Cake/Error/ExceptionRenderer.php(175): call_user_func_array(Array, Array)
#3 /var/www/html/site/lib/Cake/Error/ErrorHandler.php(122): ExceptionRenderer->render()
#4 [internal function]: ErrorHandler::handleException(Object(SocketException))
#5 {main} in [/var/www/html/site/lib/Cake/Error/ErrorHandler.php, line 131]
2013-03-06 09:15:05 Error: [InternalErrorException] Internal Server Error
Request URL: /notifications/sendContact
Stack Trace:
#0 /var/www/html/site/lib/Cake/Error/ErrorHandler.php(183): ErrorHandler::handleFatalError(256, '[CakeException]...', '/var/www/html/p...', 131)
#1 [internal function]: ErrorHandler::handleError(256, '[CakeException]...', '/var/www/html/p...', 131, Array)
#2 /var/www/html/site/lib/Cake/Error/ErrorHandler.php(131): trigger_error('[CakeException]...', 256)
#3 [internal function]: ErrorHandler::handleException(Object(SocketException))
#4 {main}
2013-03-06 09:15:05 Error: Fatal Error (256): [CakeException] Unknown status code
#0 /var/www/html/site/lib/Cake/Error/ExceptionRenderer.php(212): CakeResponse->statusCode(13)
#1 [internal function]: ExceptionRenderer->error400(Object(SocketException))
#2 /var/www/html/site/lib/Cake/Error/ExceptionRenderer.php(175): call_user_func_array(Array, Array)
#3 /var/www/html/site/lib/Cake/Error/ErrorHandler.php(122): ExceptionRenderer->render()
#4 [internal function]: ErrorHandler::handleException(Object(SocketException))
#5 {main} in [/var/www/html/site/lib/Cake/Error/ErrorHandler.php, line 131]
2013-03-06 09:15:05 Error: [InternalErrorException] Internal Server Error
Request URL: /notifications/sendContact
Stack Trace:
#0 /var/www/html/site/lib/Cake/Error/ErrorHandler.php(183): ErrorHandler::handleFatalError(256, '[CakeException]...', '/var/www/html/p...', 131)
#1 [internal function]: ErrorHandler::handleError(256, '[CakeException]...', '/var/www/html/p...', 131, Array)
#2 /var/www/html/site/lib/Cake/Core/App.php(926): call_user_func('ErrorHandler::h...', 256, '[CakeException]...', '/var/www/html/p...', 131, Array)
#3 /var/www/html/site/lib/Cake/Core/App.php(899): App::_checkFatalError()
#4 [internal function]: App::shutdown()
#5 {main}
email.php
public $gmail = array(
'transport' => 'Smtp',
'from' => array('patric.....#gmail.com' => 'Patrick Maciel'),
'port'=>'465',
'timeout'=>'30',
'auth' => true,
'host' => 'ssl://smtp.gmail.com',
'username'=>'patrick......#gmail.com',
'password'=>'.......',
'client' => null,
'log' => false
);
php info (centOs)
-bash-4.1# yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.globo.com
* epel: mirror.globo.com
* extras: mirror.globo.com
* updates: mirror.globo.com
Installed Packages
Name : php
Arch : i686
Version : 5.4.12
Release : 1.el6.remi
Size : 8.2 M
Repo : installed
From repo : remi
Summary : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
License : PHP and Zend and BSD
Description: PHP is an HTML-embedded scripting language. PHP attempts to make it
: easy for developers to write dynamically generated web pages. PHP also
: offers built-in database integration for several commercial and
: non-commercial database management systems, so writing a
: database-enabled webpage with PHP is fairly simple. The most common
: use of PHP coding is probably as a replacement for CGI scripts.
:
: The php package contains the module which adds support for the PHP
: language to Apache HTTP Server.
Available Packages
Name : php
Arch : i386
Version : 5.3.22
Release : 1.w5
Size : 1.3 M
Repo : webtatic
Summary : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
License : PHP
Description: PHP is an HTML-embedded scripting language. PHP attempts to make it
: easy for developers to write dynamically generated web pages. PHP also
: offers built-in database integration for several commercial and
: non-commercial database management systems, so writing a
: database-enabled webpage with PHP is fairly simple. The most common
: use of PHP coding is probably as a replacement for CGI scripts.
:
: The php package contains the module which adds support for the PHP
: language to Apache HTTP Server.
-bash-4.1# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imap
intl
json
libxml
mbstring
mcrypt
memcache
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
pspell
readline
recode
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
sqlite3
standard
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib
[Zend Modules]
-bash-4.1#

Apparently your PHP is not allowed to connect to the specified SMTP server. Did you properly configure your email-settings? (SMTP server, port, username, password etc).
A template for these settings is included with CakePHP in the file: app/Config/email.php.default (https://github.com/cakephp/cakephp/blob/2.2.7/app/Config/email.php.default)
You need to copy this file to app/Config/email.php and modify the settings for your environment.
After that, you'll have to specify the right configuration when sending emails
A more thorough explanation can be found in the manual:
http://book.cakephp.org/2.0/en/core-utility-libraries/email.html#configuration
update
Another option is that SELinux security-bits dissallow PHP/Apache to make network connections.
There are several security-bits, but this seems a likely candidate: httpd_can_network_connect .
You can temporarily allow PHP/Apache to make network connections using this:
setsebool httpd_can_network_connect
And make the setting 'permanent' using the -P parameter;
setsebool -P httpd_can_network_connect
For an overview of all SELibux booleans;
http://wiki.centos.org/TipsAndTricks/SelinuxBooleans

getsebool -a
Check httpd_can_network_connect
if off, set it to on
setsebool -P httpd_can_network_connect on
It works for me !!

Related

Can't run composer command on remote server

Have a problem with install Symfony vendors on remote server (VPS), because after installation composer library by server administration, I have PHP Fatal error when I run it:
PHP Fatal error: Uncaught ErrorException: proc_close() has been disabled for security reasons in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:957
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_close() ha...', 'phar:///usr/loc...', 957, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(957): proc_close(Resource id #252)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(753): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(714): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(648): Symfony\Component\Console\Application->getTerminalWidth()
#5 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(ErrorException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 p in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 957
Have PHP 7.3.15
memory_limit => 1024M
disable_functions => exec,system,passthru,shell_exec,proc_close,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname => exec,system,passthru,shell_exec,proc_close,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Maybe someone have any ideas?
If you are deploying in a shared cloud service the process won't work due to the limited resources available for your instance. I will advise you do the composer update or install on your development instance and transfer the files zipped to the host
There are multiple ways:
Contact your hosting source to allow you.
Push/Deploy the vendor from your local these way you don't need to run any composer command.

Domain is currently unable to handle this request on a Laravel project

Whenever I try to access my app online I get the following error.
[the-domain] is currently unable to handle this request.
I'm currently lost and don't even know what the problem is I've replicated my local environment on my server and the problem still persists, probably something I'm missing.
Here is my current config.
Laravel 5.7
PHP 7.2.9
Heres the stack trace form laravel.log:
[2018-09-30 12:18:28] staging.ERROR: syntax error, unexpected '|', expecting variable (T_VARIABLE) {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\F$
[stacktrace]
#0 /var/www/avanzi/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile('/var/www/invite...')
#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('Illuminate\\\\Supp...')
#2 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(22): spl_autoload_call('Illuminate\\\\Supp...')
#3 /var/www/avanzi/vendor/composer/ClassLoader.php(444): include('/var/www/invite...')
#4 /var/www/avanzi/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile('/var/www/invite...')
#5 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('Illuminate\\\\Data...')
#6 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(35): spl_autoload_call('Illuminate\\\\Data...')
#7 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(572): Illuminate\\Database\\DatabaseServiceProvider->register()
#8 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\\Foundation\\Application->register(Object(Illumin$
#9 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(548): Illuminate\\Foundation\\ProviderRepository->load(Array)
#10 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\\Foundation\\Application->registerConfi$
#11 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(206): Illuminate\\Foundation\\Bootstrap\\RegisterProviders->bootstrap(O$
#12 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#13 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#14 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Ob$
#15 /var/www/avanzi/public/index.php(58): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#16 {main}
"}
NB: This works perfectly fine in my local environment with the same PHP and Laravel version.
So I finally got it figured out for my use case.
I had the right PHP version installed but haven't enabled the extensions required by Laravel yet, so to fix this I had to go to the php.ini file for my currently installed and active PHP version and enable those extensions, here is a list of the required PHP extensions for a Laravel 5.7 project.
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
With all these extensions installed your PHP configuration should be good to go.

When I opened the project,I get back this error message

When I opened the project,I get back this error message :
Fatal error: Uncaught Error: Class 'String' not found in /dev/local/lib/Cake/Utility/Debugger.php:339 Stack trace: #0 /dev/local/lib/Cake/Utility/Debugger.php(741): Debugger::trace(Array) #1 /dev/local/lib/Cake/Error/ErrorHandler.php(219): Debugger->outputError(Array) #2 /dev/local/lib/Cake/Core/App.php(565): ErrorHandler::handleError(2, 'Declaration of ...', '/dev/local...', 25, Array) #3 /dev/local/lib/Cake/Core/App.php(565): include() #4 [internal function]: App::load('TradeLog') #5 [internal function]: spl_autoload_call('TradeLog') #6 /dev/local/lib/Cake/Utility/ClassRegistry.php(145): class_exists('TradeLog') #7 /dev/local/app/Controller/Component/UserComponent.php(61): ClassRegistry::init('TradeLog') #8 /dev/local/app/Controller/Component/PlatformAgentComponent.php(24): UserComponent->__construct(Object(ComponentCollection), Array) #9 /Us in /dev/local/lib/Cake/Utility/Debugger.php on line 339
The newly configured environment in mac os.
When I paste the project into a folder, this error occurs. What's the matter?
This is a compatibility issue between Cakephp 2.4 and PHP7 (because string became reserved word in PHP7, so Cakephp cannot use it as a class name). Using of newer version of Cakephp is suggested. Also downgrading your PHP to 5.6 could solve the problem.
You need to upgrade to CakePHP > 2.8 which is compatible with PHP7
https://github.com/cakephp/cakephp/releases/2.8.0

PDO Driver cannot connect to sql - using xampp

I have been looking for a solution for this for hours now and I found a lot of solutions, but unfortunately none of them worked.
The error I am getting is :
Fatal error: Uncaught PDOException: could not find driver in
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc:124 Stack
trace: #0
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc(124):
PDO->__construct('sqlsrv:Server=l...', 'sa', 'PWHERE...', Array) #1
C:\xampp\htdocs\site\includes\database\database.inc(1689):
DatabaseConnection_sqlsrv->__construct(Array) #2
C:\xampp\htdocs\site\includes\database\database.inc(1479):
Database::openConnection('xilenacc', 'default') #3
C:\xampp\htdocs\site\includes\database\database.inc(2350):
Database::getConnection('default') #4
C:\xampp\htdocs\site\includes\lock.inc(167): db_query('SELECT expire,
...', Array) #5 C:\xampp\htdocs\site\includes\lock.inc(146):
lock_may_be_available('schema:runtime:...') #6
C:\xampp\htdocs\site\includes\bootstrap.inc(433):
lock_acquire('schema:runtime:...') #7
C:\xampp\htdocs\site\includes\bootstrap.inc(455):
DrupalCacheArray->set(Array) #8 [internal function]:
DrupalCacheArray->__destruct() #9 {main} thrown in
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc on line
124`
This is line 124 at database.inc:
PDO::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);`
<br>
Information on what I am using:
PHP Version: 7.0.25
Mssql express 2016
Windows Server 2012
If I can provide further information, please let me know.
What I tried:
Downloading SQLSRV30 from microsoft website and putting the extensions in php -> Result: After putting the dll names in php.ini, I restarted apache and checked phpinfo(), I didn't find sqlsrv.
I double checked the information I have in settings.php - they are correct,
I even tried changing my sql pw because I thought it might be causing this,
but it didn't work.
Finally after hours of googling, I found a solution that actually worked even though it doesn't look so important.
The solution that worked with me is to install Microsoft Redistributable 2012. Kinda weird but worked!

Install impresspages to localhost - problems with db connection

When i try to install impresspages on localhost in Database installation i see this:
Can't connect to database.
I try to solve this problem by installing it on hosting(its install with no problems) and then transfer it to localhost with all database, and i edit config file. And when i go to home page i saw this:
Fatal error: Uncaught exception 'Ip\Exception\Db' in C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php:258 Stack trace: #0 C:\www\Apache2\htdocs\ip\Ip\Db.php(28): Ip\Db->getConnection() #1 C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php(258): Ip\Db->__construct() #2 C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php(226): Ip\ServiceLocator::loadService('db') #3 C:\www\Apache2\htdocs\ip\Ip\Functions.php(379): Ip\ServiceLocator::db() #4 C:\www\Apache2\htdocs\ip\Ip\Internal\Plugins\Model.php(316): ipDb() #5 C:\www\Apache2\htdocs\ip\Ip\Internal\Plugins\Service.php(9): Ip\Internal\Plugins\Model::getActivePluginNames() #6 C:\www\Apache2\htdocs\ip\Ip\Dispatcher.php(140): Ip\Internal\Plugins\Service::getActivePluginNames() #7 C:\www\Apache2\htdocs\ip\Ip\Application.php(153): Ip\Dispatcher->_bindApplicationEvents() #8 C:\www\Apache2\htdocs\ip\Ip\Application.php(319): Ip\Application->_handleOnlyRequest(Object(Ip\Request), Array, false) #9 C:\www\Apache2\htdocs\ip\Ip\Application.php(413): Ip\Application->handleRequest(Object(Ip\Request), Ar in C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php on line 258
Looks like the MySQL extension for PHP is not installed or enabled. See http://php.net/manual/en/mysql.installation.php for more information.

Categories