Using httpClient from a web application results in an error(cakephp3 App On GCE) - cakephp-3.0

I am in great trouble, so I would like you to help me.
I made a web application with cakephp3 and run it on GCE.
When trying to communicate using Http Client, the following error appears.
++++
cakephp version 3.6.2
OS CentOS7 -
++++
2018-06-20 17:14:19 Error: [Cake\Core\Exception\Exception] fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known
fopen(https:/XXXX): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
Request URL: /XXX/?callback=jQuery33100918089472164082_1529482454011
Referer URL: https://{request_host}/XXX/
Stack Trace:
#0 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client/Adapter/Stream.php(252): Cake\Http\Client\Adapter\Stream->_open(Object(Zend\Diactoros\Uri))
#1 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client/Adapter/Stream.php(82): Cake\Http\Client\Adapter\Stream->_send(Object(Cake\Http\Client\Request))
#2 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client.php(430): Cake\Http\Client\Adapter\Stream->send(Object(Cake\Http\Client\Request), Array)
#3 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client.php(399): Cake\Http\Client->_sendRequest(Object(Cake\Http\Client\Request), Array)
#4 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client.php(366): Cake\Http\Client->send(Object(Cake\Http\Client\Request), Array)
#5 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Client.php(229): Cake\Http\Client->_doRequest('GET', 'https://{request_host}', NULL, Array)
#6 /usr/local/apache/vhosts/{my_host}/htdocs/src/Controller/Api/XXXController.php(489): Cake\Http\Client->get('https:/request_host}')
#7 /usr/local/apache/vhosts/{my_host}/htdocs/src/Controller/Api/XXXController.php(406): App\Controller\Api\XXXController->__hogeAction('XXX')
#8 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Controller/Controller.php(596): App\Controller\Api\XXXController->invite()
#9 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(120): Cake\Controller\Controller->invokeAction()
#10 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(94): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\Api\XXXController))
#11 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/BaseApplication.php(228): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#12 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#13 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(158): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#14 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#15 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#16 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#17 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(98): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#18 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#19 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#20 /usr/local/apache/vhosts/{my_host}/htdocs/vendor/cakephp/cakephp/src/Http/Server.php(98): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#21 /usr/local/apache/vhosts/{my_host}/htdocs/webroot/index.php(34): Cake\Http\Server->run()
#22 {main}
I checked resolve.conf, but it is colected.
Because it is working properly on my localhost, I think that it is a problem of setting up the server and the network.
I am glad if you can help me. Thank you.

Take a look at the Firewall Rule in the GCP. Make sure that you allow ingress traffic for the ports 80, 443.
Eventually, try to test the URL connection and the ports within the GCE VM instance, or outside the GCP. Below are some examples:
$ curl http://[external-IP-vm-address]:80
$ telnet localhost 80
$ nmap <external-ip-vm-address>
$ netstat -plant
There are other network tests that you could perform. You may consult this discussion thread from Stackexchange.

Related

yii2 migration command gives warning how to fix it?

I want to download and use thyseus/yii2-message. followed steps on github.
for installation
1) $ composer require thyseus/yii2-message
2) $ php yii migrate/up --migrationPath=#vendor/thyseus/yii2-message/migrations
warning
PHP Warning: Module 'openssl' already loaded in Unknown on line 0
Warning: Module 'openssl' already loaded in Unknown on line 0
Exception 'yii\base\InvalidConfigException' with message 'The configuration for
the "user" component must contain a "class" element.'
in C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\di\ServiceLocator.php:204
Stack trace:
#0 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\di\ServiceLocator.php(260):
yii\di\ServiceLocator->set('user', Array)
#1 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\base\Component.php(172): yii
\di\ServiceLocator->setComponents(Array)
#2 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\BaseYii.php(529): yii\base\C
omponent->__set('components', Array)
#3 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\base\Object.php(105): yii\Ba
seYii::configure(Object(yii\console\Application), Array)
#4 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\base\Application.php(205): y
ii\base\Object->__construct(Array)
#5 C:\xampp\htdocs\yii2-my-app2\vendor\yiisoft\yii2\console\Application.php(89):
yii\base\Application->__construct(Array)
#6 C:\xampp\htdocs\yii2-my-app2\yii(26): yii\console\Application->__construct(Ar
ray)
#7 {main}
PHP Core Warning 'yii\base\ErrorException' with message 'Module 'openssl' alread
y loaded'
in .\Unknown:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
1st command runs successfully but second command gives some warning I didnt get it? can anyone fix it? and I also want to know what does this migration command exactly do
For the warning, check answers to this question.
For the error: Yii2-user or another user extension has to be installed first and working.

mediawiki 500 internal error when visit the home page

MediaWiki suddenly came with 500 internal error
Fatal error: Uncaught Error: Call to a member function getCode() on
null in /var/www/wiki/includes/user/User.php:1578 Stack trace: #0
/var/www/wiki/includes/user/User.php(5243): User::getDefaultOptions()
#1 /var/www/wiki/includes/user/User.php(2859): User->loadOptions() #2 /var/www/wiki/includes/context/RequestContext.php(364):
User->getOption('language') #3
/var/www/wiki/includes/Message.php(380): RequestContext->getLanguage()
#4 /var/www/wiki/includes/Message.php(1257): Message->getLanguage() #5 /var/www/wiki/includes/Message.php(842): Message->fetchMessage() #6
/var/www/wiki/includes/Message.php(934): Message->toString('text') #7
/var/www/wiki/includes/exception/MWExceptionRenderer.php(254):
Message->text() #8
/var/www/wiki/includes/exception/MWExceptionRenderer.php(358):
MWExceptionRenderer::msg('dberr-again', 'Try waiting a f...') #9
/var/www/wiki/includes/exception/MWExceptionRenderer.php(52):
MWExceptionRenderer::reportOutageHTML(Object(Wikimedia\Rdbms\DBConnectionError))
#10 /var/www/wiki/includes/exception/MWExce in /var/www/wiki/includes/user/User.php on line 1578
I assume this is a bug that might happen if you have multiple install attempts and the mysql.user is still there. I had the same problem today.
I have filed the bug as:
https://phabricator.wikimedia.org/T177768
the Problem went away after reinstalling with the following steps:
dropping database
removing user from mysql.users
strangely the "user exists" error still appeared on installation
granting access rights was therefore necessary on the mysql database.

Yii2 php yii migration

I just have installed yii2 on linux mint, using xampp, and my php yii migrate doesn't work.
basic # php yii migrate
Yii Migration Tool (based on Yii v2.0.10)
Exception 'yii\db\Exception' with message 'could not find driver'
in /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Connection.php:549
Stack trace:
#0 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Connection.php(863): yii\db\Connection->open()
#1 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Connection.php(850): yii\db\Connection->getMasterPdo()
#2 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Command.php(219): yii\db\Connection->getSlavePdo()
#3 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Command.php(894): yii\db\Command->prepare(true)
#4 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)
#5 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/mysql/Schema.php(198): yii\db\Command->queryAll()
#6 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/mysql/Schema.php(97): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/db/Schema.php(147): yii\db\mysql\Schema->loadTableSchema('migration')
#8 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/controllers/MigrateController.php(199): yii\db\Schema->getTableSchema('{{%migration}}', true)
#9 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(771): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#10 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(135): yii\console\controllers\BaseMigrateController->getNewMigrations()
#11 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#12 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#13 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/base/Controller.php(154): yii\base\InlineAction->runWithParams(Array)
#14 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/Controller.php(128): yii\base\Controller->runAction('', Array)
#15 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/base/Module.php(454): yii\console\Controller->runAction('', Array)
#16 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#17 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#18 /opt/lampp/htdocs/basic/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#19 /opt/lampp/htdocs/basic/yii(20): yii\base\Application->run()
#20 {main}
you're missing php-mysql or php-mysqlnd
run this
apt-get install php-mysql
update:
there's also a requirements.php file in yii. You might wanna check that out and see exactly what your system is missing. it could be pdo-mysql
either way, check the requirements and a phpinfo(). see what you need and make sure you have it installed and configured propperly
Just like the error message states - there is no database driver installed. Choose your database and install correct driver.
Here is the solution to the problem... yiisitenamne/backend/common/config
look for the php file main-local.php change "localhost -> 127.0.0.1"
Are you using Virtualbox?
Looks like you are missed to install php-mysql
apt-get install php-mysql
then run migration command
php console/yii migrate/up or
php console/yii migrate
I guess this is because of missing driver for PDO. Based on DB you are using, you might want to enable pdo-mysql, pdo-mssql, pdo-postgres ... in your XAMPP php.ini.

mediawiki DBLoadBalancer error while setting up wiki

I've just installed MediaWiki 1.28 on arch linux with nginx 1.10.3, php 7.1.1, php-fpm, and sqlite 3.16.2. I followed the arch wiki guide: https://wiki.archlinux.org/index.php/MediaWiki. I've installed the required PHP extensions and PHP, sqlite, nginx all seem to run fine on their own.
Now when I'm trying to do the setting up LocalSettings.php part of the MediaWiki installation, I go to 0.0.0.0/mediawiki in the browser, click the setup and get the error below. Maybe it's a setting for sqlite that has to be enabled?
[1449c8c65e65734059748f4e] /mw-config/index.php MediaWiki\Services\ServiceDisabledException from line 340 of /usr/share/webapps/mediawiki/includes/services/ServiceContainer.php: Service disabled: DBLoadBalancer
Backtrace:
#0 /usr/share/webapps/mediawiki/includes/MediaWikiServices.php(509): MediaWiki\Services\ServiceContainer->getService(string)
#1 /usr/share/webapps/mediawiki/includes/GlobalFunctions.php(3089): MediaWiki\MediaWikiServices->getDBLoadBalancer()
#2 /usr/share/webapps/mediawiki/includes/GlobalFunctions.php(3075): wfGetLB(boolean)
#3 /usr/share/webapps/mediawiki/includes/cache/LinkCache.php(267): wfGetDB(integer)
#4 /usr/share/webapps/mediawiki/includes/Title.php(3184): LinkCache->addLinkObj(Title)
#5 /usr/share/webapps/mediawiki/includes/Title.php(934): Title->getArticleID(integer)
#6 /usr/share/webapps/mediawiki/includes/content/ContentHandler.php(282): Title->getContentModel()
#7 /usr/share/webapps/mediawiki/includes/Title.php(4684): ContentHandler::getForTitle(Title)
#8 /usr/share/webapps/mediawiki/includes/parser/Parser.php(867): Title->getPageLanguage()
#9 /usr/share/webapps/mediawiki/includes/parser/Parser.php(2110): Parser->getTargetLanguage()
#10 /usr/share/webapps/mediawiki/includes/parser/Parser.php(2075): Parser->replaceInternalLinks2(string)
#11 /usr/share/webapps/mediawiki/includes/parser/Parser.php(1290): Parser->replaceInternalLinks(string)
#12 /usr/share/webapps/mediawiki/includes/parser/Parser.php(441): Parser->internalParse(string)
#13 /usr/share/webapps/mediawiki/includes/installer/Installer.php(675): Parser->parse(string, Title, ParserOptions, boolean)
#14 /usr/share/webapps/mediawiki/includes/installer/WebInstaller.php(681): Installer->parse(string, boolean)
#15 /usr/share/webapps/mediawiki/includes/installer/WebInstaller.php(657): WebInstaller->getInfoBox(string, string, string)
#16 /usr/share/webapps/mediawiki/includes/installer/WebInstaller.php(401): WebInstaller->getErrorBox(string)
#17 /usr/share/webapps/mediawiki/mw-config/index.php(54): WebInstaller->showError(Message, string)
#18 /usr/share/webapps/mediawiki/mw-config/index.php(38): wfInstallerMain()
#19 {main}
The problem was I had my php/sessions directory in /tmp. I moved it to session.save_path = "/var/lib/php/sessions" in php.ini and repeated these steps:
mkdir -p /var/lib/php/sessions
chown http:http /var/lib/php/sessions
chmod go-rwx /var/lib/php/sessions
Regardless of what Tgr said above, fixing the sessions did fix the issue for me. I'm using Apache ITK so the resolution I use is slightly different since each virtual host runs under its own unique uid.
First I create a separate directory for the sessions and change ownership
mkdir /var/lib/php/sessions-wiki
chown wiki. /var/lib/php/sessions-wiki
Then in my VirtualHosts directive I tell Apache/php where to find the session files by adding
php_admin_value session.save_path "/var/lib/php/sessions-wiki"
Then to make sure your config didn't break it.
apachectl configtest
Finally reload your config
apachectl graceful

Zend Framework - Login error - Zend_Auth_Adapter_DbTable

I have an error with the user login
Error: The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.
#0 /home/cari/library/Zend/Auth/Adapter/DbTable.php(369): Zend_Auth_Adapter_DbTable->_authenticateQuerySelect(Object(Zend_Db_Select))
#1 /home/cari/library/Zend/Auth.php(117): Zend_Auth_Adapter_DbTable->authenticate()
#2 /home/cari/application/controllers/AuthController.php(49): Zend_Auth->authenticate(Object(Cari_Auth_Adapter_Local))
#3 /home/cari/library/Zend/Controller/Action.php(513): AuthController->identifyAction()
#4 /home/cari/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('identifyAction')
#5 /home/cari/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#6 /home/cari/application/bootstrap.php(113): Zend_Controller_Front->dispatch()
#7 /home/cari/webroot/index.php(6): Bootstrap->runApp()
#8 {main}
ZF version is 1.11.6, MySQL server version is 5.5.37, running on ubuntu 12.04 with php 5.3.10.
It's a legacy application, so that's the reason of having a so old version of Zend Framework.
Any help on that?
Thanks