LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2011, 09:02 AM   #1
MarkRaats
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Rep: Reputation: 0
Create php files


Hi,

i want create a phpfile from script.

i tried 2 ways, but both give the error, permission denied

way one:
cat > /var/www/phpinfo.php << "EOF"
<?php phpinfo(); ?>
EOF
(also if i did
sudo cat > /var/www/phpinfo.php << "EOF"
<?php phpinfo(); ?>
EOF

the second way:
echo '<?php phpinfo(); ?>' > /var/www/phpinfo.php
sudo echo '<?php phpinfo(); ?>' > /var/www/phpinfo.php

greetz Mark
 
Old 01-10-2011, 10:57 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I have no problem running
Code:
cat > /var/www/phpinfo.php << "EOF"
<?php phpinfo(); ?>
EOF
So it sounds like it might be a permissions problem.
Does
Code:
echo "foo" > /var/www/test
work from the commandline? What about
Code:
echo "foo" > /var/www/phpinfo.php
? You could even try running your 'cat' command from the prompt... If the first works, but not the second, then perhaps you already have '/var/www/phpinfo.php' and it is write protected - try
Code:
ls -l /var/www/phpinfo.php
Also, please, please use code tags - it makes your post so much more easy to read...
 
Old 01-12-2011, 03:09 AM   #3
MarkRaats
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Original Poster
Rep: Reputation: 0
even the first one didnt work here
 
Old 01-13-2011, 09:48 AM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Then what does
Code:
ls -ld /var/www
print? On my computer it's got 777 permissions - this may well be the source of your problems. The fact you can't run 'echo "foo" > /var/www/test' suggests that it can't write to the /var/www directory.
 
Old 01-15-2011, 01:35 AM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
What OS are you using?
Do you have a SELinux running, if so do you have a warning from SELinux?
 
Old 01-15-2011, 08:47 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Since you said the error is "permission denied", I think that there is no problem with the command, it's jus tthe user you're logged in as doesn't have the permission to write to that file.
 
Old 01-18-2011, 03:06 AM   #7
MarkRaats
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Original Poster
Rep: Reputation: 0
install phpmyadmin

Sorry all for late reactie, was last week a bit ill, but i did
Code:
ls -ld /var/www
and it was not 777, so i make it 777 and it works all fine.

So Ill give also an answer to the others.
@graemef
Ive no idea of SelLinux is running, i thought thats only for the redhat distro's ?
I'm running Ubunut Server 10.04.1 LTS.

@ MTK358
That's correct, Ill try to explain more.
Here, I need to roll out some test application servers, LAMP and Capistrano.
So i make a bashscript that load a iso, unzip the iso and put a preceed file into the initrd and zip it again. Make a new ISO (ubuntu server 10.4. (like i said, bash script so full automatic).
A last late command is a command that download from the isoserver a second bash script and download it to the new virtual machine.

Script?
Yes, in that script you got the choice to upgrade/update/dist-upgrade in one click and also install in 1 click LAMP (working almost) Capistrano (working on it)

Why LAMP from script and not install it with ubuntu self. Because if I want a capistrano machine, I don't need LAMP. Or if i want a ubuntu server for, whatever, I dont need LAMP.

Little question.
during install LAMP (phpmyadmin) i got 2 questions and i want make that also automatic.
The first one is, give the root a password.
The command is (in bash)
Code:
mysql -u root
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('test');
I put those two lines in min bash script and i got the error unexpexting '(' on the second line (after PASSWORD)
Is that possible? from script?
the other question is, (the second question during the installation of phpmyadmin), choose for Apache2 or Lighttpd (I want that the script automatic choose for apach2 (if it is possible)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [SAMBA] How to track windows user access , create files /modify files on linux SMB efciem Linux - Server 2 05-16-2010 08:45 AM
After moving PHP files to /var/www they no longer are seen as hosted php files scheidel21 Linux - Server 9 03-01-2010 07:16 AM
Apache2 executes PHP files if specified, but not index.php will.fletcher Linux - Server 6 07-07-2009 09:27 PM
PHP & Apache - php files not processing aolong Linux - General 1 12-17-2006 03:09 AM
Linux, Create Dirs=no, Create files=yes. Possible? tisource Linux - General 4 01-12-2004 10:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration