Wednesday, February 5, 2020

Mongo DB Error

MongoDB Exception – yii\mongodb\Exception
127.0.0.1:27017: The 'cursor' option is required, except for aggregate with the explain argument


Solution :

Check the version of mongo db. I got this error while importing a database into mongodb 4.0 and database was exported from older version of mongo db 2.6 or 3.2.

I installed mongodb 2.6 in docker and imported the database. Now application was connected from docker mongodb.

It fixed the issue.

Magento Error

main.CRITICAL: Class Magento\Framework\App\Http\Interceptor does not exist {"exception":"[object] (ReflectionException(code: -1): Class Magento\\Framework\\App\\Http\\Interceptor does not exist

Solution :
You need to run commands  one by one and check if it fixes the issue.
bin/magento cache:clean
bin/magento cache:flush
bin/magento setup:di:compile

Note : Take backup of code and database before running these commands.

Thursday, January 9, 2020

Add alias for apache virtualhost with proxypass

If you are hosting an html or php website using apache, you can add DocumentRoot (path of the project Directory) in your virtualhost with ServerName and your web application can be accessed in browser easily. If you want to add Alias for such virtualhost, you can easily add Alias attribute in same virtualhost and you can show content of desired directory if alias is used in the web application url.

But suppose you have created a virtualhost to show the content of another web server like Python, Ruby or Node. You must have used proxypass to achieve this. Adding proxypass and proxypassreverse you can open content of another server through port 80 in apache.

The real issue with proxypass websites are, it is hard to create Alias for the web application urls.
Suppose you want to open content of folder images-2019 when /myimages is typed after domain. If you would use php, you could define.

Alias /myimages /path/of/images-2019
But this will not work here with proxypass virtualhost because it is already showing content of a webserver which is running on another port. This alias can not work with added configuration. To achieve this, you need to add alias in following way

Suppose you want to show robots.txt in a proxypass server(Ex- Django). Your url will be http://your-servername/robots.txt
Django will not show content of robots.txt as robots.txt path should be added in urls.py. Django only serves those content which is defined in it.
To open this url, you need to add in your virtualhost

ProxyPass /robots.txt !
Alias /robots.txt /path/of/robots.txt

Make sure you have added this above proxypass and proxypassrevese parameters, something like this.
<VirtualHost *:80>
ServerName subdomain.domain.com
ProxyPass /robots.txt !
Alias /robots.txt /path/of/robots.txt
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
</VirtualHost>

Now your servername can open robots.txt using http://subdomain.domain.com/robots.txt