Monday, 31 January 2011

Useful tools for linux

ps -eo pid,pmem,cmd
Shows the memory usage of the processes that are currently running.
updatedb
Updates the locate database.
locate String
Very fast find routine.

Monday, 17 January 2011

MySQL

If the tar contains the binaries


groupadd mysql
useradd -r -g mysql mysql
cd /usr/local
ln -s /usr/local/src/msyql-VERSION mysql
cd mysql
chown -R mysql .
chgro -R mysql .
scripts/mysql_install.db --user=mysql
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql &
.bin/mysql_secure_installation
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server

Postgresql


./configure --prefix=/usr/local/pgsql
gmake
gmake install
adduser postgres
mkdir /usr/local/pgql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start


Testing

/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

Configuring Apache/PHP

./configure --prefix=/usr/local/apache --enable-so
make
make install
vi /usr/local/apache/conf/httpd.conf
Add the places from the webpages - usually this will not actually be in the same place as you are running apache and it is most commonly /var/www/html

/usr/local/apache/bin/apachectl -k start

Upgrading

copy the config.nice file from the working version of the server to the new version directory. Use a new prefix and a different port to test the configuration - change the Listen directive to specify the new port.
./config.nice
make
make install
usr/local/apache/bin/apachectl -k graceful-stop
usr/local/apache/bin/apachectl -k start

add a call to apachectl to the rc.local file so that it autostarts.

PHP

./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/php \
--with-gd \
--with-mysql=/usr/local/mysql/ \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pgsql=/usr/local/pgsql

make
/usr/local/apache/bin/apachectl stop
make install

Edit httpd.conf to add
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>



Edit php.ini for pgsql and mysql lines removes the ; but not on the dll lines.

Sunday, 16 January 2011

Setting up MySQL

When you add MySQL to your Linux (in my case Fedora) system it has a root account but no password! This is not a very good idea and so the first thing that you need to do is create a root account and password. You do this using the mysqladmin tool as root.

# mysqladmin -u root password new_password


Where new_password is the new password (not just the word new_password).


You can now login to the MySQL using the root username and password and create a new account. 


# mysql -u root -p
...
mysql> CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password';


You need to the exit (use quit) and use mysqladmin again to create the database.
# mysqladmin -u root -p create drupalbase
# mysql -u root -p
...
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON drupalbase.* TO 'drupal'@'localhost' IDENTIFIED BY 'password';