I asked this question on serverfault but I didn't get any response. I try here...
I developped a site on my web server at home.
When I modify the translation files, I have to restart the web server Apache.
/etc/init.d/httpd graceful
Easy...
Suppose that my site is hosted on shared host.
Suppose now I need to modify the translation files.
I can't restart the server...
How do you use gettext in this context?
Are you allow to restart the server with the option graceful only?
Does the share host restart the server once a day to resolve this kind of problem?
How do you work with such constraints?
call clearstatcache();
after making translation from *.po to *.mo
the post here on the gettext function has some information for making gettext work without restarting apache:
http://www.php.net/manual/en/function.gettext.php#58310
You can rename your *.mo file and your gettext domain to flush gettext cache without restarting apache server.But in production environment,it's unsuitable.
There is no other solution than to brutally force a cache miss for each and every *.mo file every time one of them changes. Change a single string? New cache era!
I do this by writing middleware that copies all *.mo files to a timestamp-named directory (the timestamp being that of the newest *.mo file) and updates the application config with the new message path - if the newest timestamp actually changed, that is. Thus textdomains are now loaded from completely different paths, and this is what finally manages to kill the stupid gettext cache stinking dead.
Related
I have just cloned a project, so it works perfectly fine when i load it e.g: "localhost/example/contact.html", but when i click to homepage which the endpoint is "localhost/example/index.php" it asks me to save the file like that:
Asking to save the php file
I have checked everything in files such as php.ini, httpd.conf but still cant find a solution, I also reinstalled wamp 2 times.
Also the php error log gives me this error: The file C:/WINDOWS/system32/drivers/etc/hosts does not exists
Any help would be appreciated!
You need to load and enable mod_php or set up php-fpm. Afaik Wamp uses mod_php which is simpler. The reason your web browser asks you to download the php files is because you have not told the web server to treat .php files differently that .txt files.
There are plenty of resources on the interwebs about setting up php and apache:
https://cwiki.apache.org/confluence/display/HTTPD/PHP
Given that you are using Wamp, which should work out of the box, I'd say reinstall one more time and run the installer as an admin. If the issue about the etc/hosts file persists, you can create the file yourself.
However, I don't think the hosts file is necessary to run wamp or to render / run .php files.
PS: Your question is not about programming or code, so it's going to be closed because it fits better on the superuser website. Welcome to SO!
I think I'm having the same issue as this link: Apache is downloading php files instead of displaying them
I'm trying to install Roundcube on my Linode server but when I go to www.myurl.com/roundcube it downloads the php files.
I read through that link and I see people saying to add things to different files, but I don't know where to look.
I'm new to Linode, I'm used to hosts with cPanels and such. So, I need a bit of a point in the right direction.
With linode you have the raw server ie you need to ssh into it and configure it. Start with this guide.
https://www.linode.com/docs/websites/hosting-a-website
Once you have a basic site running then configure apache to use PHP.
I have a vps with zpanel installed and apache2 - php - mysql.
I'm developing a small backend for a website in php, for sites ready to publish the situation is perfect, but now I need to disable the server feature that caches php files to test instantly the correct (last modified version) of my php files.
This is because while html and js files, when edited, are reloaded correctly immediately, with php I have a long wait before it updates or I have to restart the server.
I tried to open php.ini and look for "cache" and set to "1" millisecond almost all the values with no luck.
what could I try?
P.S. it's not a browser cache problem, that's a server side problem.
Solved: inside php.ini I added a line with
apc.enabled=0
after that I restarted apache2 and now php files are updated istantly as they should
thanks for the suggestion to look into phpinfo
I am trying to open .php file in any browser but it is being downloaded..
What is the problem? somebody plz help me..
When i type localhost/hel.php in address bar of browser it shows me download dialog.
Thanks in advance
The webserver needs to know that the requested file is to be executed using the PHP interpreter. If the webserver is not installed, running or configured, the file will be downloaded very much the same as a .zip or .mp3 file would.
It is not clear what server you use, if any, so I will not post particular instructions unless you clarify.
[EDIT]
Alright, for Apache, it's quite simple. I assume you're using a UNIX-like OS, since most popular Windows packages, such as XAMPP or WAMP, come with PHP + Apache already configured and ready to go.
Apart from Apache and PHP, you also need to install mod_php, which is an Apache extension that allows the webserver to use the PHP interpreter to run PHP files. Use your favourite package manager and install the missing package. Its exact name varies between Linux distributions, so I cannot tell you which one to look for exactly, but it will usually be something along the lines of "libapache2-mod-php".
Once that is installed, go to your php.ini file and make sure the module is enabled. After restarting the webserver, PHP files should be working as expected.
Maybe this is the answer? apache2 on ubuntu - php files downloading
For second question from your comment:
Do you include
Include /etc/phpmyadmin/apache.conf
in
/etc/apache2/apache2.conf
and restart apache with
sudo service apache2 restart
?
I've been developing a PHP application using the Zend framework for awhile on a Linux-based hosting provider, and it's gone along more or less swimmingly.
The time has come to be able to develop locally on my Mac, so I configured Apache to run PHP, grabbed the source code, and symlinked /Library/WebServer/Documents to the public/ folder in my Zend web app.
That was fine. The controllers were executing and loading the correct scripts, which seemed to parse and render correctly. Except, I wasn't able to connect to my local MySQL database. I realized that I hadn't copied /etc/php.ini.default to /etc/php.ini, so I went ahead and did that. I then updated this line:
pdo_mysql.default_socket=/tmp/mysql.sock
and restarted Apache. Now, suddenly, none of the PHP executes. Instead, the raw PHP is sent back to the browser.
The effect is more or less the same as if I was trying to load a .php file directly with an Apache instance that didn't recognize the .php file extension. Based on what I've experienced, I'm guessing that maybe somewhere in php.ini there is a setting that is causing this to happen (when I rename php.ini and restart Apache, the scripts once again parse and render correctly, but again I can't hit the database) but I'm not sure where to look. Does anyone have any thoughts?
In case anyone is reading this, here's the answer that I finally discovered:
short_open_tag = On
The above needs to be set in php.ini, particularly because all of my controllers, models, helpers, etc were using short tags (e.g. ), as is common with Zend applications.