mangento 2 admin page redirect too many times error

The magento store was running fine after I initially configured, I can go to the backend and change the configurations with SSL on.

Suddenly when I tried to access the backend again later, it showed me this error on firefox, it showed the similar error on chrome also

The solution is configure the secure/use_in_adminhtml to 1, 

SELECT * FROM core_config_data where path like '%web/secure/use_in_adminhtml%';

If no entry is returned, it just means the configuration is not set.

Then do

INSERT INTO core_config_data (scope,scope_id,path,value) VALUES ('default',0,'web/secure/use_in_adminhtml',1)

Clear the cache

php bin/magento cache:flush

After that, everything is working again.

how to fix nginx php-fpm 404 error

Ok, you installed nginx and php-fpm, and happily to open your browser and entered the url, waiting for the page to load, suddenly you saw this nginx 404 error.

So you went to check your nginx configure file and made sure the webroot is correct and file permission is correct, which means they’re readable by nginx and php-fpm user.

You thought you fix the error and went back to the browser and try again, still, the 404 error.

Then you went to google and found a lot of threads from stackoverflow and serverfault, everybody is talking about file/folder permission as that’s really what 404’s root cause.

It took me quite some time to figure out the real reason for my situation. I launched a droplet from digital ocean with latest centos 7 and encountered this error.

The real cause is actually the linux is by default have linux security featured on, you have to disable it
After I ran this command, then everything is ok
setenforce 0

Hope this will help somebody later on.

migrate nextcloud to docker after failing upgrade from 12 to 13

I tried to move nextcloud to a new machine with more disk space and upgrade from 12 to 13.

I followed the steps from here to manually upgrade the package from here docs.nextcloud.com/server/13/admin_manual/maintenance/manual_upgrade.html

I downloaded the zip file and unzip it, then move the old config and data files to the new installed folder

and run the command to upgrade
sudo -u php-fpm php occ upgrade

then it complains about utf8mb4 unique key over 767 bytes, it turned out that my mariadb 10.3 is causing the issue.
Then installed MariaDB of 10.2
add mariadb.repo to /etc/yum.repos.d

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Then yum install mariadb mariadb-server

with 10.2 the utf8mb4 short unique key error is gone.

Go back to upgrade nextcloud and it was successful.

However now got another error when tried to access from browser, a lot of missing file errors like the following
2018/03/10 01:00:59 [error] 21678#0: *3145 open() “/var/www/nextcloud/index.php/js/core/merged-template-prepend.js” failed (20: Not a directory), client: xx.xx.xx.xx, server: xxxxx, request: “GET /index.php/js/core/merged-template-prepend.js?v=262b927e01e9d6c4148bbbba7b151ff3-0 HTTP/1.1”,

I googled and found this ticket github.com/nextcloud/server/issues/6540 and it said the error was fixed, i applied the fix from github.com/nextcloud/server/pull/8250 by changing the file of lib/private/Files/ObjectStore/Swift.php
Still got no luck, the missing file errors still exist.

At this stage, I turned my solution to docker containers so I don’t have to maintain all these upgrades and setup myself

Trying follow the steps here github.com/nextcloud/docker

1) yum install docker and docker-compose
make sure you have epel-release is installed before running this command by yum install epel-release

2) create docker-composer.yml
with the following, make sure set MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD
cd /data/docker
vi docker-compose.yml


services:
db:
image: mariadb
restart: always
volumes:
- /data/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud

app:
image: nextcloud
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
- /var/www/html/data:/var/www/html/data
- /var/www/html/config:/var/www/html/config
- /var/www/html/apps:/var/www/html/apps
restart: always

3) systemctl start docker
4) docker-compose up -d
5) setup the proxy server
the frontend nginx config

server {
listen 443;
server_name cloud.mydomain.com;
access_log /var/log/nginx/cloud.sslaccess.log ;
error_log /var/log/nginx/cloud.error.log;
ssl_certificate /etc/nginx/ssl/admin.crt;
ssl_certificate_key /etc/nginx/ssl/admin.key;
include /etc/nginx/nginx_proxy.conf;
}
### Default VH
server {
listen 80;
server_name cloud.mydomain.com;
access_log /var/log/nginx/cloud.access.log ;
error_log /var/log/nginx/cloud.error.log;
include /etc/nginx/nginx_proxy.conf;
}

the nginx_proxy.conf

location / {
proxy_pass http://backendip:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}

6) now go to browser cloud.mydomain.com, i can see this screen, good sign, this tells me the proxy is working well

nextcloud-frontend

7) migrate data
I had a dump of mysql from old machine, nextcloud.sql
docker cp ./nextcloud.sql docker_db_1:/dmp

8) cd to the folder where docker-compose.yml exists, then run
docker-compose exec db sh -c “mysql -u USER -pPASSWORD nextcloud < /dmp" 9) then delete the temp file docker-compose exec db rm /dmp 10) cp the previous config/config.php to /var/www/html/config folder on host and edit it set database host 'dbhost' => ‘db:3306’,
change datadirectory, ‘datadirectory’ => ‘/var/www/html/data’,

11) copy the data from previous machine to /var/www/html/data

12) change folder permission
cd to the folder where docker-compose.yml exists
docker-compose exec app chown -R www-data:www-data /var/www/html/data

13) docker cp ./apps/ nextcloud_data:/var/www/html/custom_apps
docker-compose exec app chown -R www-data:www-data /var/www/html/custom_apps
docker-compose exec app chown -R www-data:www-data /var/www/html/apps

14) go to frontend, the website is loaded correctly

AH01630: client denied by server configuration for apache 2.4

 

If you are using Apache 2.4

You have to check allow and deny rules

Check out http://httpd.apache.org/docs/2.4/upgrading.html#access

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host.

 

2.2 configuration:

Order allow,deny
Allow from all

2.4 configuration:

Require all granted

 

<Directory /path/to/document_root>

Require all granted

</Directory>

For new XAMPP, the apache is 2.4, so when adding new VirtualHost, need to change as above

export tables only, no views

Hi there In my database I have some tables and views. How can I export all the tables( and not the views ) from my database from command line?

You can use mysqldump with the option –ignore-table to exclude the views individually. Or use mysqldump and remove the views with an application/manually. grep might be an option:

grep -v “CREATE VIEW” db.dump > db-without-views.dump

 

Errors on enabling Imap module for PHP 5.3

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

OS – RHEL 5 x86_64
Configure PHP 5.3.0

./configure –with-imap=/home/krishna/courier-imap-4.6.0 –with-kerberos –with-imap-ssl –with-mysql=/usr/local/mysql –with-apxs2=/usr/local/apache2/bin/apxs –with-mcrypt –with-gd –enable-mbstring –with-gettext –enable-bcmath –enable-calendar –enable-wddx

To correct this,

Install libc-client-2004g-2.2.1.x86_64.rpm & libc-client-devel-2004g-2.2.1.x86_64.rpm

This should correct the errors.

———

Ok – here is another,

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation

Create a soft link to the 32-bit libraries.

ln -s /usr/lib64/libc-client.a /usr/lib/libc-client.a

Run configure again and you shouldn’t see this error.

U8T_CANONICAL is missing

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

This should not happen? Damned right it shouldn’t, especially when you need PHP 5.2 on the triple. Googling won’t help you, Mr. Bond – Googling for this specific error leaves much to be desired. Until (hopefully) now.

The fix is so easy, even a caveman could do it:

yum install libc-client libc-client-devel

nginx+php-fpm: Random 104 Connection reset by peer errors

I have a wordpress site with nginx/php-fpm, it was running well for a long time, then suddenly one day it starts to display blank page. More oddly is that there is no error message in the log. Once php-fpm was restarted, then the site is ok for a few pages, then it is displaying blank again. Finally i caught one error message

recv() failed (104: Connection reset by peer)

Then I googled and found this page

https://groups.google.com/forum/#!topic/highload-php-en/cLL-Z5mUZak

The solution is easy

1.yum remove httpd (other guys solve this problem just do this and step 4.5)
2.yum remove php-fpm
3.yum install php-fpm
4.service nginx restart
5.service php-fpm restart
[[email protected] /]# rpm -qa|grep httpd
httpd-2.2.15-26.el6.centos.x86_64
httpd-tools-2.2.15-26.el6.centos.x86_64