30

I am new on AMAZON EC2 Server, recently I have Installed PHP and MySQL and now I want to update file /etc/httpd/conf/httpd.conf

but the problem is, when I am going to update it, it display error like - Permission denied. What is the best way to update it?

Michael Irigoyen
  • 21,233
  • 17
  • 82
  • 125
Sumit Bijvani
  • 7,762
  • 17
  • 46
  • 79

3 Answers3

71

You have to change the file as root user. Do this:

sudo nano /etc/httpd/conf/httpd.conf

Make your changes and save with ctrl + O, Enter. Done.

nickhar
  • 18,621
  • 12
  • 56
  • 71
Syed Priom
  • 1,580
  • 1
  • 18
  • 20
  • 6
    Don't forget to "sudo /sbin/service httpd restart" it for the changes to take effect. – MikeL Oct 10 '16 at 21:13
6

I have found solution and its working...

$ sudo nano /etc/httpd/conf/httpd.conf

Sumit Bijvani
  • 7,762
  • 17
  • 46
  • 79
  • 4
    or you can just sudo vi /etc/httpd/conf/httpd.conf – Felipe Garcia Feb 27 '13 at 13:32
  • 5
    It's not a very good practice to take ownership of a system-wide configuration file whenever you need to modify it. I'm curious as to why you couldn't get `sudo` working before to edit the file. What command were you trying to use? – adamdunson Feb 27 '13 at 19:41
  • 3
    This answer proves that sudo works - OP just doesn't know what he's doing. This answer is a terrible solution (as @adamdunson also points out). Changes like these are reasons why sudo and su is introduced. – Repox Feb 27 '13 at 20:11
  • 1
    Agreed with adamdunson and Repox. ashpriom's answer is correct, this one is not a good practice. – KC Baltz Jun 10 '14 at 02:56
1

It would be prompting you a alert, that you can duplicate it. So

  • So duplicate it, store it on desktop with same name
  • Edit it for your use(remove comment '#')
  • Save it
  • Now replace the original file with this one
  • it'll prompt for your password, provide that

Now all updates you did are saved in httpd.conf Cheers

rptwsthi
  • 9,855
  • 10
  • 65
  • 102