I'm currently in the process of moving a Wordpress and Drupal website from a hostgator account to a VPS purchased by the client. The VPS has "WHM vps" installed.
I've had a whole lot of problems with this for such a simple task (such as the provider having deprecated configuration options in the my.cnf file causing MySQL to not startup correctly, and having to import a ridiculously large database from Drupal causing all sorts of problems).
But the most recent problem I've run into is the site simply not executing and just returning an Error 500. PHP is installed, but I can't find the PHP5_Module in the Apache Modules, instead there is "suphp_module" which is a shared module. PHP Error Reporting is switched on, as is error reporting in the .htdocs file.
If I add AddType application/x-httpd-php .php to the mime type it just causes the PHP files to download upon being loaded.
I'm honestly running out of ideas here, is it because php is not correctly installed, do I have to reinstall php5?
EDIT: Added the Apache Logs, not sure if the first line has anything to do with it however.
SoftException in Application.cpp:357: UID of script "/home/creative/public_html/index.php" is smaller than min_uid
Premature end of script headers: index.php
You have to assign the php to other owner and group as it is probably assigned to root:root that isn't secure, so the system prevent the execution
You can assign the webserver user and group that is likely to be apache if you're running httpd
Related
I've got the upload script which accepts the file and process it further.
Before file is processed its temporary upload path is given to clamav which will read the file outside of the PHP context and return whether there is virus inside or not.
This workflow has worked quite well until it stopped. I've debugged my script and even though file gets processed correctly on the PHP side, it doesn't exist in the tmp location given in $_FILES (during the script execution before script finishes).
$_FILES['datafile']['tmp_name'];
# This gives the location: /tmp/phpxbXzY0 correctly.
file_get_contents($_FILES['datafile']['tmp_name']);
# This returns the file content correctly.
However when I am logged in as sudo on the machine and type: cat /tmp/phpxbXzY0 there is no such file.
What's weird that it happened on all my PHP servers, but on local it all works fine and I can read the file contents with cat command.
I am running 7.2.10-0ubuntu0.18.04.1 on Ubuntu 18.04 on EC2, kernel: 4.15.0-1009-aws
Any ideas what might be the problem?
For some reason on my servers configuration of: /etc/systemd/system/multi-user.target.wants/apache2.service file was the default one.
By default it has: PrivateTmp=true while it should've been: PrivateTmp=false
That's the feature of systemd: https://serverfault.com/questions/786211/access-files-in-system-tmp-directory-when-using-privatetmp
The problem wasn't present on my local, since Apache2 isn't started by systemd therefore not restricting the /tmp path.
I need to check now why the file version has changed, since it was working fine enough. I suspect there must be unattended upgrade enabled, since I am not sure what else could cause it.
In my /etc/apache2/httpd.conf, I open it.
LoadModule php5_module libexec/apache2/libphp5.so
my vhost config
I want to ask how does apache work with the php code.
When I update the php code. I need not to send any commands to apache. I send a request to the apache, I get the right response as the updated php code making.
Does apache read the php code file when it handle every request.
Or does apache read the php code first time, then parse it, then save the parsed code into apache runtime memory? When the php file update, apache catches the system signal, reloads its runtime memory
Apache as a web server doesn't understand/know your file if it doesn't know its mime_type. So, first thing before parsing any file it checks its extension in mime.conf file and gets its mime_type based on that it parses the file. Now if your file is PHP it will start parsing it since apache is loaded with all the enabled modules one of them is libphp.so which contains the php parser and all the php methods definitions.
Here is my actual configuration vhost conf on each of my domains :
<VirtualHost *:80>
...
php_value error_log /var/log/php-logs/domainName/error.log
...
</VirtualHost>
What can I do to keep this path (one directory by domain) but to split the php logs by day (20131218.log, 20131219.log, etc. instead of error.log) ?
Wrikken (see comments) suggests simply using logrotate - but in order for this to work, you need to close and reopen every file handle referencing the log - if you are using a Linux distribution with logrotate already configured for Apache and PHP is invoked via mod_php and you don't mind the interruption to the service, then you just need to add this file to the logs rotated for Apache. But this becomes very messy if you want to keep your server up or you are using php-fpm. But you didn't tell us about the webserver, the operating system or the SAPI version.
Other solutions
(on Linux/Unix/BSD) use the system logging daemon (error_log=syslog) nd configure that to rotate the logs
on Apache, if the error_log is ini is unset, then errors are sent to stderr, and Apahce writes these to it's error log: and you can configure this to run via a bundled filter which automatically rotates logs
I have configured Amazon EC2 Server and install PHP and MySQL. I have uploaded my website on it. it is in smarty.
Problem is when I update any .tpl file, then the server return white page as output in Firefox and Chrome return 500 Internal Server Error. I have surfed everywhere on internet but got nothing.
When I update any .php file then the code work nicely. problem is only with .tpl file.
I'm willing to bet that your templates_c directory is not writable by Apache (identified as apache or httpd, and you can check in your httpd.conf file), or it hasn't been configured correctly during Smarty initialization.
You can try temporarily setting your templates_c directory to 777 permissions to test this hypothesis.
If this ends up being the case, then you'll want to assign group ownership of templates_c to apache, and set the folder permissions to 775. (They explain this in their documentation.)
An HTTP status of 500, with no page content (Chrome is just being nice and rendering a default error message for you) means that PHP encountered a Fatal Error.
You will need to find out where PHP is configured to log to (usually a file called php_errors.log) and see what the error was.
Alternatively, you could temporarily allow PHP to output errors to screen, using the error_reporting setting.
I want to create a Chrome app, but I have the same problem as this guy. When I add the .php extension and I run the app, it downloads the file.Should I do something more? I have installed PHP (if that means to download and extract the file in the same folder with my app, I'd be wrong). I'm a beginner... :(
EDIT
Some of you told me to install Apache or IIS. I said earlier that I want to create a Chrome app.
Do I need to install Apache? Where would I run it (I don't have a local host, Chrome extensions and apps use the "chrome-extension://" prefix, which means it is hosted on the browser). What about more information (you've all been helpful by now)?
EDIT 2
It turns out that Google Chrome doesn't allow developers toto run PHP inside Chrome apps.
Thanks for your help!
This means the server is either missing the PHP plugin (either CGI or otherwise) or the the server doesn't recognize that it must pass a file with the extension in to PHP for pre-processing.
If you're on a host out of your control (e.g. using GoDaddy) then make sure they allow PHP (some of the free hosts won't have PHP as they deam it an unnecessary security risk). If it's your own server, make sure you installed PHP and it's enabled.
If it DOES has PHP installed, but you're not getting it to parse, you'll need to bind the .php extension to the PHP handler using either an .htaccess file or the config.
For apache, your http.conf needs the following (assuming you already have PHP plugin):
AddType application/x-httpd-php .php
Or for something more broad, place an .htaccess file with the above code in your hosted directory.
EDIT
You mentioned you installed PHP. I'm going to assume you're using Apache, as IIS now has a Web Extensions installer that would (typically) take care of the "hard part" for you. So, having said that, open your http.conf (Usually located in C:\Program Files\Apache Software Foundation\Apache2.2\conf\ [using 2.2 as a demo version]). Within that file, at the bottom, add the following [replacing files paths to those that correlate to your own install]:
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
A better reference can be found by googling "install PHP [version] on [webserver]". Here's just one of the results I was able to locate.
Do you have a server installed on your machine? PHP is a server-side script & unlike Javascript you cannot run it without a server.
PHP files are server side code only. So you need to install a local server like APACHE to get the PHP script to execute.
PHP must be run on a web server, not your desktop. Install PHP on your webserver, then open the PHP file from a web browser via: http://localhost/yourfile.php
You need an Apache server on your computer. download xampp: http://www.apachefriends.org/en/xampp.html and put your files in the htdocs folder.
EDIT:
This will explain how to install a PHP environment: http://www.tanguay.info/web2008/tutorial.php?idCode=phpDevelopmentQuick