Tag Info

Hot answers tagged

7

The most common reason why a script works from the command line but not from a crontab is that the script depends on an environment variable. Crontabs only have a few environment variables set: typically only HOME, USER, SHELL (set to /bin/sh) and PATH (set to a system default). If you need more, you must define them in the crontab file, or source ~/.profile ...


7

Use the Dotdeb Debian stable packages. Although the documentation does not note this, the stable packages currently work fine with Wheezy/testing. After following the instructions, do: apt-get install php5-cli as root.


6

Of course any services you have open will increase your vulnerable attack surface. What runs behind those services will determine how secure and insecure you become. If you write insecure PHP scripts and host them in your newly accessible Apache site, the world will be able to (and will!) exploit them. You should seriously consider what you are making ...


6

PHP is probably trying to talk to a local SMTP server, that is, one running on the same machine as the web server. So, have you set one up? There are many to choose from. The most popular are Sendmail, Exim, Postfix, and Qmail. Try sending email using the primitive mailx client. If it can't send mail outside the machine, it's probably for the same reason ...


5

It's PHP, of course. Pipes wouldn't eat the first character of the file. PHP is reading all the characters, but it isn't outputting the first one. So far you cannot tell whether the problem is in the input or in the output: it could be that PHP is not outputting the first character for some reason. A little experiment shows that the problem is indeed with ...


4

not root not root SuEXEC Depends. 644 for files and 755 for folders are a safeish default. Don't change ownership of anything to www-data unless you want php to be able to edit the contents of that file/folder Irrespective of anything else you do: folders need read and execute permissions for the user to find files; files need read permissions for the ...


4

Starting from the bottom: I don't think it matters. Well, it matters a little bit. CentOS uses RPM, but many other distributions don't. How you package things really depends on where you expect to install them. How do I turn it into an rpm? You need to create an RPM SPEC file, which is a collection of metadata about your package and the rules ...


4

Appears you have both suEXEC and SELinux enabled, so you will need to hack around to permit execution of the php script, to start off check CGI scripts are permitted: getsebool -a | egrep 'cgi|builtin_scriptin' If not: setsebool -P httpd_enable_cgi 1 setsebool -P httpd_builtin_scripting 1 Also check the php scripts have the necessary extended flag, ...


4

From the question and from the output, it seems that you only have the RPMForge repo enabled and nothing more. /etc/yum.repos.d/rpmforge.repo:name = Red Hat Enterprise $releasever - RPMforge.net - dag /etc/yum.repos.d/rpmforge.repo:enabled = 1 So run: # yum repolist disabled repo id repo name ...


3

As an addition to the answer by Gilles who suggest recompiling the complete PHP package you can also wait for PHP 5.4. In 5.4 I restructured the realdine functionality that all required parts are in the readline module, so you can built that stand alone. $ wget ...php-5.4.0.tar.bz2 $ tar xjf php-5.4.0.tar.bz2 $ cd php-5.4.0/ext/readline $ phpize && ...


3

I think you need to wrap your code in <?php ... ?>. Try this file: <?php phpinfo(); ?> By default, the contents of a PHP file are HTML that is sent untouched out to the browser. The markers <?php and ?> mark the start and end of PHP code that is interpreted by PHP.


3

Modify your shell script to enter the php scripts directory before executing it, and then return back. cur=$(pwd) cd /var/www/html && php ./createview_customer.php cd "$cur" or better modify your php script to find its directory first and open the file in that dir $dirpath = dirname(__FILE__); $handle = fopen("$dirpath/available_data", "w");


3

You can look at the return code from the ssh command. If the command fails, ssh will return a non-zero exit code. According to the PHP documentation, the system and exec functions both allow you to capture the return code of a command in the *return_var* parameter.


3

Instead of, or in addition to, writing to a database, have you considered writing to a named pipe? You could create one named pipe per user and then create a process to watch each named pipe. When the 'restart' command comes, immediately restart the process. This is not a complete solution and can be improved upon, but it should give you an idea of how you ...


3

One of the standard ways of doing this is to download the php source code from http://php.net/downloads.php and compile it with ./configure --prefix=/opt/php/5.3.15 or something to that effect. Then, your new php will not conflict with any system packages. Note that on Fedora, you will need to install a bunch of -devel packages to build php with the ...


3

What about official way? yum update php php-* -y Never ever mess up system with downloading tar/gz while official package exists. Also look here : http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-centos-5.3-lamp Be sure to restart apache after upgrade : service httpd restart


3

PHP uses the dotted integer convention for versions (i.e. the version number should be considered a sequence of integers, not a floating point number). 5.3.10 was the release after 5.3.9. That means 5.3.18 is sixteen releases after 5.3.2. Note that this is the standard way of interpreting a version number with more than one dot in it. Single-dotted ...


3

Not exactly answering your question (h3rrmiller gave you a good answer already), but I would suggest not doing this. This will break all your mysql connections when your ssh connection dies, and they can only be reestablished when you set up a new ssh connection. If you're doing this to encrypt the mysql traffic: mysql supports SSL for connections too, ...


3

Debian's cron, like many other modern variants, read jobs in files under directories called /etc/cron.d, /etc/cron.hourly, etc., in addition to the traditional /etc/crontab. In particular, the job you see comes from /etc/cron.d/php5 which is installed by the php5-common package.


3

Well, for a start, PHP isn't doing shell_exec through bash in your case, it's doing it through sh. This is fairly obvious from the exact error message. I'm guessing that this is controlled by whatever shell is specified in /etc/passwd for the user that the web server is running as and shell_exec doesn't capture stderr, in combination with that when you run ...


3

As pointed out by Mat in the comments, unless you specifically set up auditing it is highly unlikely that the command as such is deliberately stored anywhere and kept in a directly accessible form. grep -lR ... / as root might be an enlightening experience (you may want to remount everything noatime first...). However, there is always a "but". In this case, ...


3

I don't see anything inherently wrong with doing it this way. The only thing that pops out is that someone could play games with the contents of db2restore if that file were owned by db2inst1 and not root, for example. I'm also going to assume that this playschool database is not on the production system. If it is then this becomes a bad idea, if he ...


3

Is there a way I can define my own DNS server address when trying to resolve the host? Yes, we can using following method . Method #1 - All Method trying to resolve from Google Public DNS, you can change as you wish. nslookup 180.76.5.168 8.8.8.8 Method #2 dig -x 180.76.5.168 @8.8.8.8 Method #3 host -W 2 180.76.5.168 8.8.8.8


3

The PHP.CGI.Argument.Injection exploit allows remote code execution on PHP if used as a CGI and if version <= 5.3.12 or <= 5.4.2. Your seeing those lines in the firewall's logs does not mean that you're vulnerable, only that someout out there thinks that you might be. To that effect, but that is only my opinion and I had several experts disagree ...


3

You can download the latest version from the official page and follow the instructions inside the compress file for the installation. Alternatively if you want to use the debian repositories, you can add deb http://ftp.us.debian.org/debian testing main contrib non-free in the file /etc/apt/source.list Also add Package: * Pin: release n=testing ...


3

You need to configure exim4 to relay as a smarthost. There are a (lengthy) set of instructions here at the Debian wiki: GmailAndExim4, but it's really easy to get up and running. Your PHP sendmail_path is good to go.


3

You need to rebuild libpcre with position independent code. The straightforward way to do that is to build or install the libpcre shared objects (e.g. libpcre.so) which are built with -fPIC. Since the library archive was in /usr/lib/x86_64-linux-gnu, the shared objects might be there also. Try adding -L/usr/lib/x86_64-linux-gnu to LDFLAGS of php. This will ...


3

Built-in Webserver If your goal is to learn PHP I highly recommend you use PHP's built in webserver, available on PHP version 5.4 and up. cd ~/mywebsite php -S localhost:8080 You now have a webserver, tied to the ~/mywebsite directory, and accessible in the browser at http://localhost:8080 This all runs in user mode so you don't need to sudo ...


3

What could be causing this problem? Have you checked that the actual site always returns documents with an extension? There is no protocol which requires this and it is completely normal to not use them; the document type is determined by the http headers and not any suffix on the address. Of course, your file browser does use file extensions to ...


2

Moving that comment to its own answer, looks like your /etc/apt/sources.list is faulty. Edit it to remove the line that contains debian-security, and replace it with deb http://ftp.nl.debian.org/debian/ lenny main contrib non-free for the main distribution, deb http://security.debian.org/ lenny/updates main contrib non-free for security updates, and ...



Only top voted, non community-wiki answers of a minimum length are eligible