Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I manage a VPS of my client. He wanted a backup solution includes some folders and mysql databases. OS is Ubuntu, web server is apache. I don't want my client to mess with ssh or ftp.
I think i can save database backup files and trigger PHP's exec function from a wab page to zip folders and database backup files, then give a link to download this zip file.
This is technically possible but i wonder if there is a better solution except automatically copying backup files to another server. Because creating backups anytime is required in my situation.
There are lots of possibilities, here is a very simple one we use every day:
create a backup script (e.g. in bash) with the usual suspects as mysqldump, tar and date
make sure, this backup script locks against double runs
create a cron job, that runs every minute, checks if a flagfile exists, and if yes starts the backup script and then clears the flagfile
if you want, create more cron jobs (e.g. a daily one), that do nothing but set the flagfile
create a trivial PHP script, that just touches the flagfile to trigger an adhoc backup
You can download the finished backup package, once the flagfile is cleared (again check via a trivial PHP script)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
In my php website, I call a python script using theano and running on GPU.
However, when calling this python script from php, it seems apache doesn't have any permissions on GPU so the program falls back on CPU, which is far less efficient compared to GPU.
How can I grant apache rights to run programs on GPU?
I would split that up, save the requirement as event in some storage (redis for example or even rabbitmq) and listen to that with some daemonized script (cron would be a bad joice since its hard to make it run more often than every minute). The script will update the storage entry with the results and you can access it again in your http stack. You can implement the functionallity via ajax or utilize a usleep command in php to wait for the results. If using a while loop, dont forget to break it after 1 second or something, so the request is not running too long.
Your problem might be the configured user, that executes the php binary - it maybe not permitted to access those binaries on your system. Typically its the www-data user. By adding the www-data user to the necessary group, you might be able to solve it without splitting all up. Have a look at the binary's ownerships and permissions to figure that out.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I got trouble with some hackers, they hacked into our website, so I cloned our server to a new one, and then reset the github on that server.
I heard about rsync can find out what is different about 2 servers. Is it possible for rsync ? Can I export that list of files to a text file?
Thanks your help, got hacked by use old version of wordpress >_< I was crazy with this from last couple days.
The comment by Marty is good - the rsync command as written will do a dry-run (-n) to show you what files were added/deleted/changed between the $TARGET and $SOURCE locations so you can then inspect or diff them to see if there is any malicious code.
Additionally, in the past when I've dealt with hacked WordPress installs, it is important to find the exploitation vector. Often times PHP shells get uploaded via some insecure script or plugin which gives the attacker a command based web shell to view files and run commands etc.
To find these files, the following command is helpful:
grep -E '(?:(shell_)?exec|system|eval)' /path/to/wordpress/* -R
This might yield something like:
wpte.php: eval($_POST['p1']);
Which in this case, wpte.php was a malicious PHP shell script that got uploaded to one of my client's servers that someone then used to run commands and upload more files. These scripts usually use one or more functions like eval or shell_exec to run commands input from the web shell.
Going from there, you can check the server access logs for hits to the malicious script and then further search the logs for the IP address(es) that accessed that script to potentially find how the uploaded the script or other hits resources they accessed.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am creating a website and am expecting somewhat normal usage. I am setting up the system for now with 1 Apache Server and 2 DB servers. I want any DB operations to be reflected in both DB servers so that I can have 1 server as Backup. Now how do I do it ?
The ways I can think of are :
Perform same operations in both DB from PHP. This seems like a terrible idea.
Update 1 DB and sync both DB servers periodically. This seems better.
Is there any better way to achieve this ? How is it done in Enterprises ?
If you're using MySQL, there is quite powerful built-in replication.
Check out the docs
A terrible idea is to have backup each time a new operation happens. No modern, nor old application works this way. Even Windows System Restore makes backup on scheduled times, not on each operation.
I'd suggest you to make an sql dump script. And schedule a cron job wich will run it once a day, or twice a day. If you really need the data on the server immediately (assuming, you need if one of the DB servers crashes, your app continue working immediately with the backup server) you can make an import script, which will run once the dump finishes.
If you are not in the special case, when you need once the first DB server is shutdown'd, to have another one opened, you can just store the dumped sql files on the machine and not load them on real database, if they are not needed.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have the following problem:
The website I made for a friend has been infected with malware. When I tried to clean it, by replacing files that I found to be different to the ones I uploaded, with my original files, after a short time, the files were different again. The file permissions are all 644, and the folders 755. It is as if the one who infected the files has access to change them whenever I change them back. Can anyone help me since I am very new to this kind of problems?
First things first: report this to your webhost immediately! Secondly change all of your relevant passwords!
That being done, there are a few possible causes:
Your parent webhost has been compromised, in which case there is nothing you can do except move to a better host.
Your website contains a vulnerability that is being picked-up by kiddies with their vuln-scanners. Be sure to audit your code to ensure that no user action can result in your website's filesystem being touched inappropriately; also check for SQL injection avenues.
Your website uses a widely-distributed application, such as WordPress, that has not been patched - this is a major problem.
Your own PC has been compromised and ne'erdowells have used a keylogger or other software to discover your FTP or SSH account details, and are abusing your website. Run a local scan and audit everything to ensure your bank account is being raided either.
This isn't a code-related problem. This isn't the place for your question.
But: It's likely that a program is running on your server and re-infecting the files. I'd recommend either taking it to a professional malware removal service, or (my preference) burning the server in a fire and allowing a new server to rise from the ashes. Then install an AV suite on the new server.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
My situation is that I want to rotate maillog of postfix anytime after my php script send the mail.
So that I can analyze log file, disapatch different error message to different sender and after that delete the rotated log file preventing original maillog from growing too large.
My Freebsd version is 8.0 release.
Is it possible that I don't have to install any extra program tool increasing difficulties in setting up system.
thanks in advance
Couldn't logrotate be helpful to you? It's a rather standard tool for log rotation on nix systems.
If I were in your situation, I would use logrotate and write custom scripts to do what I want with the logs: since you don't express your needs in a precise way, it's hard to give precise answers.
When you say you want to use PHP for that, I hope for you that you don't mean "from within the web server", but "as a system script language". I would really not let the Apache PHP module, for instance, manipulate the system logs. I would ensure that they're out of its reach, actually.
Additionally, I think it might be a question for Server Fault or UNIX / Linux instead.
FreeBSD uses newsyslog(8) for its log rotation. It is configured by /etc/newsyslog.conf and by default uses a daily rotation for /var/log/maillog.
If really necessary you can trigger a non-scheduled rotation by calling newsyslog -F /var/log/maillog. But IMHO it is preferable not to and only to change the policy in newsyslog.conf because that a) requires no additional code and b) means that the config documents the system's state.