httpd.conf edited but after 2 days it change to default file

bt4

Well-Known Member
Jul 1, 2010
69
0
56
hello

i have edit and i change some line from this file
but after some day it change to defaul file i dont know how it happen
/usr/local/apache/conf/httpd.conf
 

skulluminati

Registered
Jul 29, 2011
4
0
51
On some server configurations httpd.conf is constructed automatically from templates, you may need to edit those. Check the comments in the httpd.conf file to see if it mentions anything about being automatically constructed and where those template files may be.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
What lines were edited? The httpd.conf file should not be directly edited, but include files would need to be used instead. Anytime /scripts/rebuildhttpdconf is run or EasyApache is processed, the httpd.conf file will be rebuilt using the following locations:

/var/cpanel/templates/apache2/
/var/cpanel/userdata
/usr/local/cpanel/
/var/cpanel/conf/apache/

The include files that should instead be used for adding entries to Apache are dependent upon the section you wish to have included. The non-VirtualHost includes are at /usr/local/apache/conf/includes location, while the VirtualHost include files would need to be created at /usr/local/apache/conf/userdata/ location.

For example, if you wanted to add an entry into an existing domain's VirtualHost, you'd create for Apache 2 / Apache 2.2 for http (rather than https) the following folders:

Code:
mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com
Where username is the cPanel username and domain.com is the domain name. In that location, you would then place a file called newconf.conf (it simply needed to end in .conf) and put the contents into that file that should go into that domain's VirtualHost entry.

You can read documentation about the VirtualHost includes at the following:

Changes Contained within a VirtualHost Directive

Thanks!
 

bt4

Well-Known Member
Jul 1, 2010
69
0
56
thanx for ur answers
i edit <Directory "/">

and i found the problem, how it going back to default file
when i restore some host via WHM the httpd.conf is back to default file

how i can stop that?
if i restore some host ddt change httpd to default file
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Please provide exactly what you are changing in this portion:

Code:
<Directory "/">
    Options All
    AllowOverride All
</Directory>
Without the exact details, I cannot provide a resolution to solve it.
 

bt4

Well-Known Member
Jul 1, 2010
69
0
56
<Directory "/">
Options -ExecCGI -FollowSymLinks -Includes IncludesNOEXEC Indexes -MultiVie$
AllowOverride AuthConfig Indexes Limit FileInfo Options=IncludesNOEXEC,Inde$
</Directory>
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You've provided an incomplete copy of the entry. I'm pretty certain it cannot end in $ for -MultiVie$

Please provide the full entry you are using for me to test adding it so I can get details on how it can be added without it being removed.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
I am unable to open the file on my Mac. Is it that difficult to simply provide the full lines for those 4 lines? Rather than using nano, simply use vi which doesn't cut lines short...
 

Infopro

Well-Known Member
May 20, 2003
17,112
514
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
i'm waiting...
I think cPanelTristan was hoping for this actually. From your httpd.conf:

Code:
<Directory "/">
    Options -ExecCGI -FollowSymLinks -Includes IncludesNOEXEC Indexes -MultiViews SymLinksIfOwnerMatch
    AllowOverride AuthConfig Indexes Limit FileInfo Options=IncludesNOEXEC,Indexes,Includes,MultiViews,SymLinksIfOwnerMatch
</Directory>
Attachments above have been removed by me.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

With the correct Directory contents fully provided finally, I was able to test getting this to work. All you have to do is distill the changes to maintain those changes to that portion of httpd.conf file. These commands worked perfectly fine for me to keep that entry to replace the prior one I had:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110801
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
When you run the /scripts/rebuildhttpdconf part, that will show you if a change made directly to httpd.conf will be kept or not. In this instance, distilling the change did keep those lines upon an Apache rebuild.

In the future, please always provide the exact lines you are adding and what section they are replacing to make things go a lot quicker. Please do not attach the full httpd.conf file either.

Thanks!