Magento 2 - Symlinks not created in dev mode - css

Environment:
- Magento 2.3
- Mode: Developer
- Cache: Disabled
- empty: pub/static, except .htaccess
- empty: var/cache, var/composer_home, var/page_cache, var/view_preprocessed
From there it is my understanding that if you reach the website through a browser, considering there are no static files ready to use yet, then Magento will either copy (production mode) or symlink (developer mode) the required css/js to pub/static folder for the theme used (as well as parent themes for the required files), so that the website can load properly and accordingly.
But what happens instead in developer mode, it creates a single file:
pub/static/frontend/Vendor/theme_name/en_US/requirejs-config.js
Any idea why the symlinks are not generated and what's happening, why this single file requirejs-config.js is generated?
PS: we do not want to deploy static content.

You can try this command
bin/magento dev:source-theme:deploy instead of bin/magento setup:static-content:deploy -f

In command line :
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Clear your navigator's cache and try to reload your page.
If it still doesn't work :
php bin/magento setup:static-content:deploy -f
php bin/magento setup:upgrade
Clear your navigator's cache and try to reload your page again.
Hope it's help.

try this
php bin/magento setup:static-content:deploy -f en_US yourlang_YourLang

Related

Magento 2 Deploy CSS Updates

I am trying to figure out a way to move in css updates in production mode without any downtime or maintenance mode enabled.
For example, if I update something in theme's style.css, I will need to run the commands below to get the css updates included in the merged css file.
rm -rf var/view_preprocessed/*
rm -rf pub/static/frontend/*
php bin/magento setup:static-content:deploy
php bin/magento cache:flush
But this will create downtime. Running deploy command along will not update the css.
Any suggestions?

WordPress file permissions on CentOS7 requiring sudo

I'm running WordPress on my VPS with CentOS 7 LAMP stack.I've followed this guide to set permissions, i.e. I've run
sudo chown apache:apache -R *
to ensure that my wordpress directory is owned by apache:apache.
I've also set WordPress directory and file permissions with these commands:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
(I had to prefix the above commands with sudo)
Normally I manage the server by logging in through SSH using myuser, where myuser belongs to the apache group and the wheel group.
I have 3 problems:
Any file CRUD command in the WordPress directory still requires me to prefix the command with sudo, or else I get a permission error. Since myuser belongs to apache and apache owns the directory, I'm confused as to why I still need to prefix the commands with sudo.
Similar to problem 1, any git command such as a git pull requires me to prefix the command with sudo or else I get a permission error.
When I try to automatically update theme files from my WordPress dashboard web interface, I get permission errors. Interestingly, I'm able to install/update plugins via the WordPress dashboard without any permissions errors.
Any ideas on what I'm missing?
Look at:What does mode_t 0644 mean?
644 means:
* (owning) User: read & write
* Group: read
* Other: read
CRUD is a write command, so you're not allowed to do that. Either you change to 664 or keep using sudo. Basically any writing procedure on the file system would not be allowed without sudo since your user is not the owner (event though he is in the group).
#fortuneRice, CentOS7 features selinux enabled by default, which is often the cause of many hard-to-understand file permission errors.
I would suggest the following:
Edit /etc/sysconfig/selinux
Change SELINUX=permissive (or whatever SELINUX is currently set to in the file) to SELINUX=disabled
Reboot your server (not just the apache web server, but the whole machine)
Disabling SELINUX completely is not a good idea, therefore if this procedure works, you should re-enable SELINUX and fix its configuration.
Configuring SELINUX can be a difficult task, so I suggest you read up on google how to do that :)
chown -R -f user:apache /path of the directory
I also faced that issue and solved this problem by changing the PHP handler.
it is important to use PHP Handler that will run as the file owner.
After I installed HTTP2 and another few features on the way, I changed the PHP handler.
I am running WHM/CPanel on my VPS, and I fixed my issue following these steps:
Under WHM > Software > EasyApache 4 > Customize
Look for the: mod_suphp under the Apache Modules tab and make sure it is enabled, and if you just turned it on to install, follow step two.
Go to the Review tab and click the Provision button to save.
Under Whm > Software > MultiPHP Manager look for PHP Handlers tab.
Choose suphp as the handler for the current PHP version.
That's it. It was the PHP handler.
Edit: I notice that suphp had a conflict with one of my user uploads directories that I am adding dynamically to images a watermark. It seems the suphp handler had permission to upload but doesn't show the pictures.
I also tried the lsapi for the PHP Handler, and it seems to work correctly with the file's permissions and attaching via the .htaccess file watermarks for images.

symfony assetic dir. does not exist

I've dumped assets using the folling command:
php app/console assetic:dump
I've got a Runtime exception:
The source file "c:\EasyPHP\data\localweb\projects\symfony\src\LV\IndexBundle/Resources/public/images/" does not exist.
It seems to me strange that:
the / goes to \Resources only, after it is /
the directory images does exist in public
no CSS work. I even tried internal CSS in layout.html.twig. Nothing changes.
OS: Windows 10
Try to remove vendors and re composer install, clear cache directory.
If problem isn't solved after that, please share your config.yml here

Exec with PHP-FPM on nginx (under chroot) returns nothing

I've created a nginx server in a chroot at /srv/http with php-fpm. Both services use the http user and it works fine. The problem comes when I try to run an exec command such as
echo shell_exec('/usr/bin/ls');
There is no output at all on the web page or in the errors. I've also tried
error_log(shell_exec('/usr/bin/ls');
and still nothing.
Things I've Tried or Know:
safe mode off
exec enabled
user is http (using phpinfo())
display_errors = on
error_reporting = E_ALL
sudo /usr/bin/chroot --userspec=http:http /srv/http ls works fine
Can create file and read from it using file_puts_content and fopen/fread
tried shell_exec,exec,system, and passthrough - nothing worked
tried appending 2>&1 to the end of the command and nothing
I've copied all the executables and libraries necessary over
all libraries, binaries, and everything under /srv/http/www (where the webpages are) have executable and read permissions
doc_root is www
As far as I know, everything works in the chroot, except shell commands through php-fpm. Anyone have any idea where I went wrong and how to fix it?
This may sound stupid but you must just copy /bin/sh (not /bin/bash!) to you chroot.
For example see this question: How do I change the shell for php's exec()
If you chroot to some directory, then this directory becomes the root for all your PHP scripts. That means, that if you execute /usr/bin/ls from within PHP, it will try to exectue /srv/http/usr/bin/ls instead.
You can copy the executable to that directory - but be aware of the security implications. If you copy critical system executables into the chrooted directory you basically bypass the positive effects of chroot.
I get no output for
echo shell_exec('/usr/bin/ls');
either. Presumably because ls isn't a file but a built-in command. Running:
echo shell_exec('ls');
outputs:
css demos favicon.ico images js path.php robots.txt routing.php test
which is the list of files in my root directory for the site.

MAMP / Symfony: MAMP overrides date.timezone setting from php.ini, Symfony fails

I'm trying to configure Symfony2 framework in MAMP.
In php.ini I have correctly set date.timezone, however, it appears that MAMP somehow overrides the setting and uses system time instead.
As a result, Symphony's config.php page sends this warning:
Warning: date_default_timezone_get()
[function.date-default-timezone-get]: It is not safe to rely on the
system's timezone settings. You are required to use the
date.timezone setting or the date_default_timezone_set() function. In
case you used any of those methods and you are still getting this
warning, you most likely misspelled the timezone identifier. We
selected 'America/New_York' for 'EST/-5.0/no DST' instead in
/Applications/MAMP/htdocs/Symfony/app/SymfonyRequirements.php on line
434
Symfony fails to show start page until this has been fixed. What would be the solution?
Thank you!
Check if there are two php.ini files in your system. You may be adding the date.timezone line in one of them but MAMP is using the other.
If that doesn´t work for you try adding the following line at the beginning of your web/app.php and web/app_dev.php files, (as the error message suggests):
date_default_timezone_get('Europe/London');
Hope it helps.
I am still working on figuring out why and how MAMP overrides the php.ini date.timezone settings, however, I have found the quick fix solution within Symfony php files, which solved the problem, at least for now.
I added the following bit of code:
date_default_timezone_set ('America/New_York');
-- at the top of Symfony's config.php and app_dev.php files, immediately after the opening php tag, at the very top of the script. This removed the warning message and got Symfony working on MAMP.
I foresee having to add the same code to some other php files inside Symfony as I keep hacking at it, which shouldn't be a problem. Or I may figure out how to override MAMP's overriding.
Still, this is a workable solution.
copy
cp /etc/php.ini.default /etc/php.ini
change permisions
chmod -R 775 /etc/php.ini
edit
sudo vi /etc/php.ini
search for date.timezone and change it to (example):
date.timezone = "Europe/London"
Are you in command line? cause command line may get a different php.ini than MAMP.
To see which is your php.ini from command line, you can do:
$ php -i | grep 'Configuration File'
(reference: How to find the php.ini file used by the command line?)
Try to set "date.timezone" in "/etc/php.ini", or wherever it says is your php.ini file.
You can also change your php.ini file:
$ php -help | grep "php.ini"
-c <path>|<file> Look for php.ini file in this directory
Like...
$ php -c /Applications/MAMP/conf/php5.5.14/php.ini ...
For example:
$ php -c /Applications/MAMP/conf/php5.5.14/php.ini -i | grep 'Configuration File'
If your problem is how to make changes in php.ini file on MAMP PRO, try to edit the template.
File -> Edit Template
You can see in MAMP manual, page 24
More info is here
In MAMP 3.0.1 the php.ini file in the corresponding php folder version you are using has the value date.timezone declared after a semicolon which turns it into a comment rather than a command. In the php.ini in C:\MAMP\conf\php5.5.12 (or your php version) delete the semicolon in line 703 and define your local time according to guidelines http://php.net/manual/en/timezones.php.
Hope this works for you :)
Like Pedro Luz mentioned, you have to set the timezone in your mac's php.ini and not MAMP's.
Don't forget to restart your mac's apache:
sudo /usr/sbin/apachectl restart
This solution worked for me:
[OK]
Your system is ready to run Symfony2 projects

Resources