Magento2 : Admin redirection issue - magento2

I have installed Magento2 on my WAMP server. And when I tried to access http://127.0.0.1/magento2/admin/ it's redirecting to http://localhost/admin/admin/dashboard/ (An invalid URL)?

the file app/etc/env.php should start like this.. check your backend frontName :)
<?php
return array (
'backend' =>
array (
'frontName' => 'admin_xu4zwa'
),
);

I think your magento installation foldername and value in table core_config_data field "base_url" is not same.
In terminal run command: php bin/magento info:adminuri , say it shows: admin_mkp
In database run sql: SELECT * FROM core_config_data WHERE (scope LIKE '%_url%' OR path LIKE '%_url%' OR value LIKE '%_url%') LIMIT 50
Check value of web/unsecure/base_url say value is: http://127.0.0.1/magentoxyzfoldername/
Now your adminurl should be like this: http://127.0.0.1/magentoxyzfoldername/admin_mkp
note: magentoxyzfoldername is your magento installation folder name.

We can also check the admin url by using command
$ php bin/magento info:adminuri

You need to check the following
Check Your admin backend name
make sure you have mod_rewrite enabled in apache
Make sure you have installed magento properly if not try to reinstall it.

change the base_url value in table core_config_data to http://127.0.0.1/magento2/ instead of http://localhost/magento2/, you can find the record in the table using
SELECT * FROM core_config_data WHERE path='web/unsecure/base_url';.

change base url from core_config_data table and check frontName in app/etc/env.php file. Hope, this will help.

After installation of Magento2 site into a new location, you need to run all magento commands, after changing url in core_config_data table and changing connection in app/etc/env.php file.
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

I think you need to set web/unsecure/base_url and web/secure/base_url in core_config_data table with your url like : http://127.0.0.1/magento2/
Or you can set this setting from admin side
Stores > Configuration > General > Web:
Base Urls
Base URL : http://127.0.0.1/magento2/
Base Urls (Secure)
Base URL : https://127.0.0.1/magento2/

I hope it will works!
First you can check the file app/etc/env.php and check backend frontName should be 'admin' like below.
return [
'backend' => [
'frontName' => 'admin'
],
...........
...........
...........
];
And then run this command
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

try switch to Developer mode
bin/magento deploy:mode:set developer

Check your base_url on database core_config_data table
And also check app/etc/env.php frontName value.
After that:
set module:developer
setup:upgrade
clean cache

Open Mysql and run below mysql query:
UPDATE `core_config_data` set value = "http://127.0.0.1/magento2/admin/" WHERE path like "%base_url"
After run Mysql query you need to run below command in ssh terminal for flush cache or you can direct delete magento root var/cache folder. After that try to open magento admin it would work.
php bin/magento cache:flush

need to enter host entry for local
sudo nano /etc/apache2/sites-available/000-default.conf
Add the path to your Magento pub/ directory to the DocumentRoot directive
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/magento2/pub
ServerName hostname.magento.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html">
AllowOverride all
</Directory>
</VirtualHost>
sudo systemctl restart apache2

Related

Magento 2 does not load css or js after setup: upgrade

My website is in default mode only. After run "setup:upgrade" my web does not load the resources css or js. "Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
Any idea what might be causing this problem?
If you are using Linux then change the mode to developer and then run php bin/magento cache:flush from the document root of the webserver.
If you are using Windows then please follow the below steps:
change the mode to developer
run php bin/magento cache:flush from the project directory
run bin/magento setup:static-content:deploy -f from the project directory
Please let me know how it goes!
Try this
sudo su
cd /var/www/html/magento2
Set permissions to the files as follows
find . -type f -exec chmod 644 {} \;
Set permissions to the directories as follows
find . -type d -exec chmod 755 {} \;
Set permissions to special directories: as follows (these commands solve your file uploading issue)
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
Please check the .htaccess file in pub/static/.htaccess. If not then please add it.
thanks!!
Solution -
In file /etc/apache2/apache2.conf Navigate <Directory /var/www/>, Change "AllowOverride None" to "AllowOverride All" 2. Add this at last in env.php located at <MagentoRootDirectory/app/etc>
`'system' => [
'default' => [
'web' => [
'unsecure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
],
'secure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
]
]
]
]`
In etc/di.xml, Search <item name="view_preprocessed" xsi:type="object"> Under that Modify this Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Add this in db INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;
Add this in db UPDATE core_config_data SET value = '0' WHERE core_config_data.path LIKE '%web/seo/use_rewrites%';
Run this command, sudo a2enmod rewrite

Magento 2 errors on cache:flush cache:clean | Need to set permission to 777 afterwards

Everytime I run:
php bin/magento cache:flush
php bin/magento cache:clean
I get the following message when reloading the page:
An error has happened during application run. See exception log for
details.
exception.log:
ain.CRITICAL: Exception: Warning: file_put_contents(/var/www/magento2/var/cache//mage-tags/mage---914_CONFIG_SCOPES): failed to open stream: Permission denied in /var/www/magento2/vendor/colinmollenhour/cache-backend-file/File.php on line 663 in /var/www/magento2/vendor/magento/framework/App/ErrorHandler.php:61
When I then run:
sudo chmod -R 777 var/ pub/
The error is gone.
How could this happen everytime I clean cache and what should be done to back trace/solve this issue?
The root of such type of issues is same: the user that run web-server differs from the user which runs console command.
Preconditions
You should define what user run your web-server.
$ ls -la
This command could who creates var/cache and so on.
Let's decide that web-server run under www-data user.
Solution 1
$ sudo -H -u www-data __some_command_here_
This format allows you to run the command under web-server user. So application will have same rights as a server (user www-data).
So you command php bin/magento cache:flush transforms to
$ sudo -H -u www-data php bin/magento cache:flush
Solution 2
Add web-server's user to your user to the same group.
$ id
uid=1001(ygl) gid=1002(ygl) groups=1002(ygl),112(nopasswdlogin)
this one will show information about the current user.
$ sudo usermod -a -G www-data
this command will add www-data to yourGroupName.

CSS not loading properly magento2

CSS not loading properly in magento2. Getting below error:
NameError: variable #button__shadow-active is undefined
in _buttons.less
Do you use wampserver ?
Go to your wampserver icon and click on it and than
Apache->apache modules->rewrite_module[enable this]
After this start all services and check it ........
Css not loaded properly means static content rendering problem so,
Remove cache,page_cache,view_preprocessed from var table
Give full permissions to var folder
Run static command in magento root folder php bin/magento setup:static-content:deploy
now Roload the site
First Replace .htaccess.sample with .htaccess in root
Add .htaccess in pub/static
https://github.com/emizentech/magento2/blob/master/pub/static/.htaccess
Edit & Replace Apache config file & replace given details below.
sudo vi /etc/apache2/apache2.conf
From
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
From
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
sudo service apache2 restart
rm -rf var/cache/*
rm -rf var/generation/*
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
chmod -R 777 pub var
This will solve your css issues, admin 404 issues , link/url 404 issue , version-xxx issue.
As the error says your less variable is missing and not found.
It means these are possible reasons for your error:
Invalid .less variable declaration.
If you are importing variables from another file - you have an invalid declaration of that file in the XML or you didn't import that file on your less file with #import "custom-variables.less";
There is a typo in your main .less file
Without code, there are only guesses. Please provide us a code so we could check it more precisely. Also, check your .log files there can be some hints.
CSS not loading properly due to static deploy not push the file to pub/static directory.
You have to follow the below steps.
rm -rf var/*
rm -rf pub/static/*
php bin/magento setup:static-content:deploy
chmod -R 7777 var pub/static
Try this,
set permission on /var and /pub folders to 777
ssh using this command
php bin/magento setup:static-content:deploy

NTLM with Apache + CentOS 5

I tried to install NTLM on CentOS 5 with Apache 2.
I did the following steps.
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/S/SP/SPEEVES/Apache2-AuthenNTLM-0.02.tar.gz
tar zxvf Apache2-AuthenNTLM-0.02.tar.gz
cd Apache2-AuthenNTLM-0.02
perl Makefile.pl
make install
After that I added to my httpd.conf the following:
<Directory “/var/www/htlm/secure”>
Options Indexes
PerlAuthenHandler Apache2::AuthenNTLM
AuthType ntlm,basic
AuthName Secure Access
require valid-user
PerlAddVar ntdomain “YOURDOMAIN domaincontroller backupdomaincontroller”
PerlSetVar defaultdomain YOURDOMAIN
PerlSetVar splitdomainprefix 1
PerlSetVar ntlmdebug 0
PerlSetVar ntlmauthoritative off
</Directory>
Now I tried to restart the httpd service but I got the following error:
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 1018 of /etc/httpd/conf/httpd.conf:
Invalid command 'PerlAuthenHandler', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]
Do I need to add something else or do I need to add a module?
Thanks
Regards Paul
According to http://www.webmasterworld.com/forum13/4292.htm, you need mod_perl too.

MySQLi installed but didn't enable

guys
I've intalled the mysqli.so from the source:
[root#li460-123 no-debug-non-zts-20090626]# pwd
/usr/lib64/extensions/no-debug-non-zts-20090626
[root#li460-123 no-debug-non-zts-20090626]# ls
mysqli.so pdo_mysql.so
[root#li460-123 no-debug-non-zts-20090626]#
And then i enable it in /php-install-2/etc/php.ini (where my php installed):
extension=/usr/lib64/extensions/no-debug-non-zts-20090626/mysqli.so
Then i restart my nginx server but the phpinfo didn't show MySQLi.
[http://sobugou.com/phpinfo.php][1]
My php is installed at
[root#li460-123 php-install-2]# pwd
/disk1/php-install-2
[root#li460-123 php-install-2]# ls
bin etc include lib man sbin share var
[root#li460-123 php-install-2]# cd etc/
[root#li460-123 etc]# ls
php-fpm.conf php-fpm.conf.default php.ini
[root#li460-123 etc]#
Could anyone help ? thanks !
When you look at http://sobugou.com/phpinfo.php, you can see Loaded Configuration File is set to (none). This means that your php.ini configuration file is not being used. Problem can be fixed using --with-config-file-path=PATH flag during PHP compilation.
See more: php.ini is nonexistent Loaded Configuration File (none)