Friday, May 28, 2004

update or upgrade apache and php for redhat linux

Ok, If you came here from a search engine directly to this page, You should note that i have failed the first attempt to update or upgrade apache and PHP and get them to work together, After formatting, Reinstalling RedHat 9, I am ready to roll again, I do and it works

.......

I will explain everything here so a nice guy like me wouldn't have to bear all the dependency and installation location trouble, We will compile and build right from the first time here, Unlike last time (i already did, im just posting what i did)

........

Thursday, May 27, 2004

Still a prepost

Have reinstalled rh9
Just added 1 line MTU=1400

Went to
http://rhn.redhat.com/help/latest-up2date.pxt

https://rhn.redhat.com/help/ssl_cert.pxt

Upgrading MySQL that ships with redhat 9 to MySQL 4 (4020)

Ok, here it is...
LEGEND: RED = COMMANDS , Navy Blue = Output, Green = Things you should change inside a command

Ok, you might want to go get a cup of cofee before you start, But maybe you should delay that, When you compile the MySQL code, the process is going to take probably a bit longer than 15 minutes, you can delay the cofee till then

I started the computer, Logged in as root ! Then i took the following steps

NOTE: If you have just installed REDHAT 9, This should work without reading, all you need is to copy the red text and execute it on the terminal window line by line, You should then be done...

Another NOTE: By The time you read this, I would have reinstalled REDHAT once again, and verified that it is step by step and correct... So our copy paste idea should work if you install RedHat FULLY and then come here to copy paste...

A VERY imprtant note: Backup your entier DB before you start, This can be done simply by doing the following
The line you see in red (command) might span 2 lines, it should copy normally and paste on one line, the directive --all-databases should include all your databases and all tables within them, in short this is more like a backup mysql till i install a new one

Open a terminal Window...
CD to the directory you want to store your backup file in
issue the following command
mysqldump --opt -u YOURUSERNAME --password="YOURPASSWORD" --all-databases > file.sql.bin

Instructions on restoring this at the bottom of this post

I dont know why it works when you add the .bin and lets you down when you have a very big DB and leave it .sql, either way, make sure the file is there and has all your databases (it should)

I downloaded the new MySQL source code from http://dev.mysql.com/downloads/ to a /root/Installs/ directory, The curent version was 4.0.20 (4020)

I unpacked the comressed package (MySQL Source) to a directory and then renamed it to mysql_src


Then i started by opening a terminal window (in GNOME)

Then navigated to the directory ( /root/Installs/mysql_src )

i did the following to display packages that depend on each other and uninstall them as follows.

First i ran

rpm -qa | grep -i mysql

This resulted in a list of MySQL related files

mysql-devel-3.23.54a-11

perl-DBD-MySQL-2.1021-3 (this one depended on mysql-3.23.54a-11)
libdbi-dbd-mysql-0.6.5-5
mysql-3.23.54a-11 (depended on mysql-server-3.23.54a-11 AND MyODBX-2.50.39.11)
MySQL-python-0.9.1-6
qt-MySQL-3.1.1-6
mod-auth-mysql-1.11.12
----------------------

Started uninstalling as follows

rpm -e mysql-devel-3.23.54a-11
rpm -e perl-DBD-MySQL-2.1021-3 (did not work, Needed to uninstall mysql-3.23.54a-11 first, But you go ahead, Skip this line or enter it, makes no difference, Just go step by step... This step did nothing and will be repeated forward in the text)
rpm -e libdbi-dbd-mysql-0.6.5-5
rpm -e mysql-3.23.54a-11 (Did not work as well, Will get back to it in a minute, Needed uninstall of qt-MySQL-3.1.1-6 and mod-auth-mysql-1.11.12 first)
rpm -e MySQL-python-0.9.1-6
rpm -e qt-MySQL-3.1.1-6
rpm -e mod-auth-mysql-1.11.12

So, we still have mysql-3.23.54a-11 and perl-DBD-MySQL-2.1021-3 to remove, The second needed the first to be removed and the first needed the following to be removed

So lets take out
mysql-server-3.23.54a-11
MyODBX-2.50.39.11
Than we can uninstall mysql-3.23.54a-11

rpm -e mysql-server-3.23.54a-11
rpm -e MyODBX-2.50.39.11

Now lets takle the remaining 2 out

rpm -e mysql-3.23.54a-11
rpm -e perl-DBD-MySQL-2.1021-3

Ok, we shoule be done, We run
rpm -qa | grep -i mysql
again and nothing appears, We are done Uninstalling our own MySQL



Great, So we have the source code of MySQL, We have uninstalled our outdated database and ready to install the database, if you are like i was 2 days ago, you might think compiling and building the database is hard, it is not its a piece of cake, just copy and paste the following red parts, If you are more experienced and wish to configure the directives yourself, go ahead, i dont think it counts much, When you do, check that the ./configure finished successfully, if not tweak the directives, if you lose hope, just copy and paste out directives again, Nothing changes on your system untill you run the MAKE command...




So now we need to make a usergroup called mysql and a user named mysql

Add Group mysql

groupadd mysql

Add User mysql
useradd -g mysql -c "MySQL Server" -d /dev/null -s /sbin/nologin mysql

Ok, I am assuming you have Changed Directory to the directory where you have the source code (in this example /root/Installers/mysql_src

The code you will see now has the directives i have chsen, To see your options you can execute the following

NOTE: At this point i have restarted my computer and loged in as root again, I am not sure if this step in necessary, But if you want to do it, Please bookmark this page so you an carry on where you left.

./configure --help | less
Now with the direcives i have chose, it would look like this

chown -R root.root *

./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql.sock --without-comment --without-debug --without-bench


Then hit enter key (they will have spanned multiple lines but that is OK (actually it is why we have the \ at the end of each line :))

This should take a few minutes, But the longer part is not this, it is yet to come (where you go get that cofee you wanted since the start)

First, We run the make clean to get rid of any old fies from the old install, it should take a minute or two.

make clean

Now, You can run the next line and go get the cofee

make && make install

You are neerly done, But still you have to configure MySQL for functional use and you have to restore that database you backed up at the start (if you did)

1- Installing a database on the database engine (Should create the data directory and tables for privilages and the default users

./scripts/mysql_install_db

Now there are a few nice instructions on that, You should take note of them, eventhough we will include them here...

Now we need to move the ownership of the newly installed MySQL directories to the new owner mysql

chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data

Now you should chose what kind of setup you need based on one factor, How large is the database this database engine is going to run ?

small, medium, large, OR huge

then you should copy one of the files - my-medium.cnf , my-small.cnf , my-large.cnf , my-huge.cnf to /etc/my.cnf

cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf

If you get an error message about the data directory missing
something has probably went wrong in the mysql_install_db step above.
Go back and review it, If in fact this is the case, Do that step ALONE again


Now lets load some settings into MySQL

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig



Now, we need MySQL Loaded whenever we reboot

cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig --level 3 mysql on



Now, to make it runnable from anywhere on the command prompt

cd /usr/local/mysql/bin
for file in *; do ln -s /usr/local/mysql/bin/$file /usr/local/sbin/$file; done


now, Lets RUN MySQL (your nearly there)
cd ~
/etc/rc.d/rc3.d/S90mysql start



Now, we need to change the password for the root account, We also need to drop that root account that requiers no password (for security)

mysqladmin -u root password YOURNEWPASSWORD

mysql -u root -p

mysql> drop database test;
mysql> use mysql;
mysql> delete from db;
mysql> delete from user where not (host="localhost" and user="root");
mysql> flush privileges;



Now to quit (mysql) and return to shell ($), Type \q at the mysql prompt.

Now to restoring the database...

mysql -u root --password="YOURPASSWORD" < /path/to/xxx.sql.bin

Failed to update, Going to retry

Ok, so it has been too good to be true so far, Something wrong just had to happen...

The main reason why i need a Linux Box Installed (besides learning and getting something free) was to setup a LAMP (Linux Apache MySQL PhP), so my installation of readhat 9 included PHP 4.2.2, MySQL, And Apache 4

Now what i had to do is Upgrade the installs, I needed PHP 4.3.6, MySQL 4.0.x and Apache 2.0.49...

So, i decided to start with Updating MySQL and it all went marvoulosly fine ( Since this is a sucess i will post it alone and link to it here

Maybe i should also mention that i did a couple of stupid things while installing MySQL that resulted in errors like "can't connect to local server through socket /temp/mysql.sock" and other things, I fixed those, Understood why they happened and posted the right way to upgrade or update mysql, And then after Reinstalling RedHat 9, I used my own step by step guide to updating MySQL and it works flawlessly

Then the apache install also went fine, But something had to go wrong (HINT: PHP wouldnt work with apache :( !

I already overcome my problems, so if you want to get right to the issue (how to install PHP and APACHE over the version that comes with redhat 9 click here)

And since i am doing this for learning reasons, i need to know what went wrong, what was the right way to do it and how to fix it, I will mention what went wrong here in detail and how i fixed it, Then i FORMATED the computer, Clean installed RedHat Linux 9 and did it again, Let me show you a bit about the details...

Tuesday, May 18, 2004

Finished setting up MySQL and APACHE

Ok, i have already got RedHat9 installed and connected to the internet (DHCP through windows 2000)


how to setup linux (Same for many but i used RedHat 9) to get internet access from a windows 2000 (windows2k) via ICS ( DHCP )

Now i had to setup APACHE 2 and MySQL on the new linux machene, Worked like a charm on the first time :)

All you have to do to start apache is run the command httpd (you will find a RUN area in the red hat or start here menu...)
Ok i am donw with apache, For my sql i have to build a table of database users and there privilages, you can do that by issuing the command mysql_install_db in terminal window...

When done it will remind you of a few things

First: Change your MySQL ROOT password
/usr/bin/mysqladmin -u root password 'new-password'
Since rot initially has no password you don't enter a password, The only thing you should change above is 'new-password with 'Your-Password', And leave the ' ' in place....
Then it tells you how to start the MySQL Daemon (The MySQL engine)

You can start the MySQL daemon with:
cd /usr ; /usr/bin/safe_mysqld &



All i had to do to run the command '/usr/bin/safe_mysqld' & after building the database of privilages (by running the command mysql_install_db)

Chmod everything in the mysql directory to 777

Ok, we have both PHP and MySQL Running, But we want them to run at boot time

So all we need to do is add those 2 lines to the file /etc/rc.d/rc.local , This file is the last file that your linux will run for initialization....
I found this line in there
touch /var/lock/subsys/local
And i added 2 more lines like this
----
httpd
/usr/bin/safe_mysqld
----
Now to see if it is working, I reboot and Yes, both APACHE and MySQL are running, PHP is already setup, php.ini and httpd.conf need some fixing, but i can do that later ! Everything is working fine

Ok, all is fine, APACHE working, PHP on apache is working, Now i need to import my files from the server

Ok, i found the application, Its a browser that uses SAMBA i think, I just clicked the red hat and it says NETWORK SERVERS, You open the browser and it gives you one icon (WORKGROUP) Thats the name of my network, i open that and i see the machenes on the network !!

I double click my Windows machene, Prompts for username and password, I enter same as my windows login, and ok i have everything i need, copy paste to the /var/www/html directory, I feel so at home with linux now, doing everything i needed


I will post all the applications i found out about (that are also free and i had to pay for back in windows, For example i have found a nice FTP client called gFTP that works like WS_FTP (allot better in my oppinion) and its free....


WOOOOOOHOOOOOOO

I have evetything ready for a new LINUX FREE BASED LIFE

Monday, May 17, 2004

New to linux

Ok, i intent to write all the articles strait to the point in this BLOG

The idea : I have never used linux before, i am totally new to this operating system, i have to learn allot about it, and im starting to like it), Im sure there are many people just like me who can save time by reading from this blog.

So, i installed linux last night, And have it connected to the internet !

Setup: My brother's compute (connected directly to the internet) is a windows 2000 station, all other computers on the network are windows XP (My sister, dad, mom, other sis), except for mine now, it is running REDHAT 9...

I thought about fedora but it needed a download, and i might consider it when core 2 is released (i have learned all this new cool stuff today), i chose redhat 9 because there is allot of info and help on it everywhere on the internet

Ok, lets get to the real thing...

1- Installation, I simply booted from the first RedHat CD, it asked me some easy questions like what password do you want for root (root is the top administrator) then what exactly will this computer be (the options were something like server, workstation, firewall, or something like that) so i chose custom and then scrolled down and chose install everything, Since i have heard it is much easier to uninstall than install !

--CoOoL i am using mozilla and i just hit a button that asked me to save a screen shot, Il find out what that button was in a minute since it seems so usefull-- Neat stuff
--Found it, its the print screen button---

Install finished, I have had no problems up to now, i started linux then setup went on askng me to create a USER since logging in with root for daily use is not such a good idea....

i created a username, then logged in with root (since there are changes i have to make), opened the mozilla web browser (Mozilla is the original netscape, AOL takes its netscape code from mozilla), then tried to open a website, it didn't work, it halts at sending the request

So lets see whats wrong, My brother is using ICS (internet connection sharing)on his computer, Thats DHCP client, i should obtain the IP automatically and just lke in windows (where i define MTU in the registry

--The checkup, I want to check if i am on the network, I open Nautilus and find WORKGROUP in there, i open that and i see all computers around me, i can access them all and copy files from them, Ok my ethernet card is working fine and i am on the network

-- I open the file /etc/sysconfig/network-scripts/ifcfg-eth0 (eth0 seems to be my ethernet cards name) and it has the following in it -Seems it is already setup for DHCP those are the contents

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

Now i add the line
MTU=1400
Still does not work ! even after restarting the network (you can restart the computer if you like but there should only be such a need in linux if you rebuild the kernel)


So what now ? i am going to leave hat MTU there since it looks correct

So lets try to access a website by IP address ! For example lets go to http://207.36.196.245/info2device.com/
It worx ! but if i go to http://www.info2device.com it does not !

Looks to me like something is wrong with my DNS !

I go to the Hat (lke start in windows), System Settings, Network....
I see ETH0 (my ethernet card), And a tab with DNS !

Ok i think i know where the problem is !
So lets set the nameservers to some nameservers i know
I set the first to 216.219.239.7
And second to 216.219.239.8

Those are the nameservers for valuwer (ns1.primarydns.com and ns2.primarydns.com), Ok i plan to chane those soon when i find out how the system works, for now lets keep them this way, I restart the network, open the web browser (first mozilla than konqueror), Okay everything seems to be working fine...

I point my browser to blooger.com and im making this blog

Ok i restarted my computer, i check the file /etc/sysconfig/network-scripts/ifcfg-eth0 and i find new stuff in there,

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
MTU=1400
USERCTL=no
PEERDNS=no
TYPE=Ethernet

Sounds to me like the DNS ! Ok, it is cool, as long as it works...

Now i need to setup apache and MySQL and a bunch of things more, I will get to you when i finish and tell you all about my adventure with that ! For now, localhost works if i run the command httpd (yes just the wotd httpd), But it runs with its own config file, i will have to fix everything and il be posting again in a few hours.