So, you just did something that broke your entire everything. You’ve tried restoring backups, or you don’t have any. You’ve tried correcting the cPanel userdata files, but for some reason, httpd.conf just isn’t changing. And then you notice this file httpd.conf,v – this beautiful file, that contains all of the changes you’ve ever made to httpd.conf, and has exactly the information you need in it. But how do you convert httpd.conf,v to httpd.conf? Using RCS!
- Make backups
- Find the revision you need
- Revert
- Restore httpd.conf
You got into this situation because you didn’t make enough backups, you silly little lamb, so let’s not make that mistake again.
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.broken
cp /usr/local/apache/conf/httpd.conf /root
cp /usr/local/apache/conf/httpd.conf\,v /root
The file is formatted with revision numbers, dates, author information, etc. It’ll look something like this.
1.517
date 2012.04.11.10.27.03; author root; state Exp;
branches;
next 1.516;
Here’s an example of a revision with actual data. Let’s say you accidentally deleted this vhost and you need it back. We’ll be using the revision from this code block in the following examples.
1.365
log
@"Modified by /usr/local/cpanel/scripts/killvhost After removing vhosts"
@
text
@a8725 32
<VirtualHost 1.2.3.4:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /home/test/public_html
ServerAdmin webmaster@@test.com
## User test # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup test test
</IfModule>
<IfModule concurrent_php.c>
php4_admin_value open_basedir "/home/test:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
php5_admin_value open_basedir "/home/test:/usr/lib/php:/usr/local/lib/php:/tmp"
</IfModule>
<IfModule !concurrent_php.c>
<IfModule mod_php4.c>
php_admin_value open_basedir "/home/test:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir "/home/test:/usr/lib/php:/usr/local/lib/php:/tmp"
</IfModule>
<IfModule sapi_apache2.c>
php_admin_value open_basedir "/home/test:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup onst onst
</IfModule>
CustomLog /usr/local/apache/domlogs/test.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
CustomLog /usr/local/apache/domlogs/test.com combined
Options -ExecCGI -Includes
RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
</VirtualHost>
@
Let’s take this apart a bit.
1.365 – this is our revision number. This tells the RCS command to roll back to the version with this data. Location the correct revision to restore is the most important part of the process.
Now it’s time to go ahead and revert the files. Make sure you’re in /root and not overwriting your existing httpd.conf first.
cd /root
co -l -r1.365 httpd.conf
This will ask you if you wish to replace the existing httpd.conf. Say yes. The /root/httpd.conf file will be overwritten with the RCS version from revision 1.356.
cp /root/httpd.conf /usr/local/apache/conf
/etc/init.d/httpd restart
Overwrite your existing httpd.conf file and restart Apache. That’s it!
Final notes: since this is cPanel, the httpd.conf you just made will eventually get overwritten with the broken one from cPanel configs. This is just a stop-gap measure to get the sites up while you investigate the real problem. Good luck!