lamp for centos

sunt multe tutoriale pe net despre ce ar trebui sa instalezi in calculator ca sa ai un lamp ( apache + php + mysql ) functional.
Mi-a venit ideea sa rezumez toate comenzile intr-un script, astfel ca toata instalarea sa arata doar ca un apel de script:

MYSQL_PASSWORD=mysecretpassword

### activare mod debug in bash
#set -x

### install mysql
echo -e "\n\nInstall MYSQL\n\n"
yum install mysql mysql-server
chkconfig --level 235 mysqld on
/etc/init.d/mysqld start

echo -e "\n\nMYSQL: set password for root@localhost : $MYSQL_PASSWORD\n"
mysqladmin -u root password $MYSQL_PASSWORD

echo -e "\n\nMYSQL: set password for root@`hostname` : $MYSQL_PASSWORD\n"
mysqladmin -h `hostname` -u root -p password $MYSQL_PASSWORD

### install apache2
echo -e "\n\nInstall Apache2\n\n"
yum install httpd
chkconfig --levels 235 httpd on
/etc/init.d/httpd start

### install php
echo -e "\n\nInstall PHP\n\n"
yum install php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
/etc/init.d/httpd restart

### test php
echo -e "\n\nWrite /var/www/html/index.php test file\n\n"
echo "<?php phpinfo(); ?>" > /var/www/html/index.php

### install phpmyadmin
echo -e "\n\nInstall phpmyadmin\n\n"
## activam repositoryul RPMForge
echo -e "\n\nActivate rpmforge repository"
cd /tmp/
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.`uname -m`.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.`uname -m`.rpm

yum install phpmyadmin

## in urmatorul fisier trebuie comentat <Directory>... pentru a permite toate conexiunile ( nu numai localhost )
echo -e "\n\nIn file /etc/httpd/conf.d/phpmyadmin.conf comment the <Directory>\n"
read -p "go to file..."
vi /etc/httpd/conf.d/phpmyadmin.conf

## in fisierul asta treb modificat $cfg['Servers'][$i]['auth_type'] = 'http';
echo -e "\n\nIn file /usr/share/phpmyadmin/config.inc.php set variable:\n\n $cfg['Servers'][$i]['auth_type'] = 'http';\n\n"
read -p "go to file..."
vi /usr/share/phpmyadmin/config.inc.php

/etc/init.d/httpd restart

echo -e "\n\n\nDone.\n\n"

Download from here

In script se mai cere din cand in cand si interventia utilizatorului… yes… no… password :)

NB: scriptul instaleaza si phpmyadmin

apache rewrite to www

ideea e ca pe orice domeniu se poate intra in doua moduri : domeniu.tld si www.domeniu.tld ( iar daca nu se poate intra prin una din aceste modalitati – aceasta reprezinta anomalii ). Dar, totusi, se doreste raspandirea pe internet doar a unui link dintre acestea 2: doar domeniu.tld sau doar www.domeniu.tld, pentru ca ele pot fi vazute de motoarele de cautare ca 2 domenii diferite.

Acum reprezint o modalitate de a lasa ambele domenii valide si facem doar astfel ca domeniu.tld sa redirectioneze automat catre www.domeniu.tld .

Acest lucru este posibil cu modulul rewrite din apache2. Si pentru asta modificam fisierul .htaccess cu urmatorul continut:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domeniu\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domeniu.tld/$1 [R=301,L]

acum orice accesare a url-ului domeniu.tld va returna un cod de status : 301 = Moved Permanently ( A status code of 301 tells a client that the resource they asked for has permanently moved to a new location. The response should also include this location. It tells the client to use the new URL the next time it wants to fetch the same resource. ) si va redirectiona catre www.domeniu.tld

install vim on centos 5.4

legatura dintre cele 2 e una mai speciala :)

vezi ce ai instalat :

[root@ns2 ~]# yum list 'vim*'
Installed Packages
vim-common.x86_64        2:7.0.109-6.el5       installed
vim-enhanced.x86_64      2:7.0.109-6.el5       installed
vim-minimal.x86_64       2:7.0.109-6.el5       installed
Available Packages
vim-X11.x86_64           2:7.0.109-6.el5       base

vezi ce exista prin repozitory-uri:

[root@ns2 ~]# yum search vim
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System.
vim-common.x86_64 : The common files needed by any version of the VIM editor.
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements.
vim-minimal.x86_64 : A minimal version of the VIM editor.

Ideea e ca implicit centos 5.4 vine instalat doar cu vim-minimal, iar daca ai cerinte mai avansate de la vim trebuie sa instalezi vim-enhanced

[root@ns2 ~]# yum install vim-enhanced.x86_64