Thursday, 30 August 2007
MySQL Password Reset Root
If you're reading this - chances are, you're an idiot. I know this as I am also an idiot as I installed a development server recently and forgot the root password for mysql. Yes I should have written the password down, no I didn't. here's the steps for resetting the root password on a working linux server;
1.) First login as root via ssh
2.) kill the mysqld service and all other mysql running processes e.g.
#> service mysqld stop
#> ps waux
ps waux gets a list of all running processes
use kill to stop any running mysql processes eg kill 6194 (kill pid).
3.) After stopping/killing mysqld, run the foillowing line;
#> mysqld_safe --skip-grant-tables &
4.) You are now logged into mysql safe mode. Cut and paste the following lines
mysql -u root mysql
UPDATE user SET password=PASSWORD("your_password") WHERE User="root";
FLUSH PRIVILEGES;
exit;
5.) then start up the mysqld service;
#> service mysqld start
That's it - all done. Now remember to write down ur password this time u idiot!
Tuesday, 28 August 2007
SELinux CURL Problem
skip to solution
Recently, I made a recursive xml sitemap generator tool, which quickly generates a sitemap, calculating how popular certain pages are related to how may linke they have internally. This helps make quick, good xml sitemaps that google likes as it follows the rough popularity that google sees of each page.
So I spent about 3 hours on this script - making it proper kick ass only to discover that when I upload the script from my dev server to my live server - the fucker doesn't work! not only that, but there's nothing reported in /var/log/messages.
After updating php-curl using yum and turning my firewall off with still no luck - I decided to get heavy handed and ask my server people to reinstall a newer version of fedora.
so afterspending another half a day setting up ftp/httpd/iptables/mysql/php/bind/etc. I uploaded the xmlsitemap generator and it still doesn't fucking work!
Oh where do I start? 'Livid' doesn't even come close - not only had i wasted the best part of a day updating my server - I didn't even manage to fix my sitemap script!!!
However, i did now have a message in /var/log/messages;
comm="httpd" dest=80 scontext=root:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket
After much googling, I found this solution;
Solution
in the cli, type the following
#> getsebool -a
#> setsebool httpd_can_network_connect true
The first command displays the current SELinux settings, the second should change the SELinux setting so that httpd can access tinterweb.
I think this is one of thise annoying SELinux bugs that no-one really understands as there's not much on google about it - however i've found loads of people moaning about it and not getting it to work. Therefore I hope this helps someone!
Saturday, 11 August 2007
Vi Search and Replace
I use vi as a text editor and I thought I'd add this example fo search and replace using vi;
:1,$s/sometexttoreplace/newtext
In the above example, 1 represents the first line, $s represents the end line.
One important thing to note is that you need to escape any characters like dots, for example;
:1,$s/suffolkweb-design\.co\.uk/suffolk-web-design\.com
would be the way you change domain names from suffolk-web-design.co.uk to suffolk-web-design.com
Wednesday, 8 August 2007
Fedora Startup Scripts
After a bit of fiddling around, I found what appears to be the best solution for me, using ntsysv and init.d. Here's how it's done;
1.) make a new file in the /etc/init.d/ directory
2.) add your script to this file with the following lines at the top;
#!/bin/bash
# chkconfig: 345 85 15
# description: of your file
3.) enter this in the shell;
chkconfig --add startup_filename
4.) type ntsysv - your startup script should now be in the list, checked and ready for action!
It's that easy!
Friday, 3 August 2007
Apache Proxypass and IIS
However, he only had one IP address could only demonstrate one server at any given time, until he discovered Apache's ProxyPass with added wildcards.
Here's the apache Virtual Host;
ServerName ms.mysite.com
ProxyPreserveHost On
ProxyRequests Off
ServerAlias *.ms.mysite.com
ProxyPass / http://192.168.1.2/
ProxyPassReverse / http://192.168.1.2/
In this example, all subdomains of ms.mysite.com now forward onto the IIS server.