天天看點

LAMP yum install

This tutorial shows a quick way of installing a LAMP server (<b>L</b>inux + <b>A</b>pache + <b>M</b>ySQL + <b>P</b>HP/Perl together commonly known as <b>LAMP</b> Server.) on CentOS and RHEL server systems. 

Apache Web Server 2.0

MySQL Database Server 5.0

PHP Scripting Language 5.0

phpMyAdmin - Web based MySQL Administration Tool

Webmin - A free web based hosting control panel

Apache is the most popular Web HTTP server for a Linux servers.

yum install httpd httpd-devel

We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side. <b>/etc/httpd/conf/httpd.conf </b>- Apache configuration file location.

/etc/init.d/httpd start

MySQL is a widely used open source database server on most Linux servers and can very well integrate to PHP and Apache server on CentOS/RHEL.

yum install mysql mysql-server mysql-devel

If you attempt to type mysql in command prompt, you will be getting this nasty error.

<b>ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’</b>

This is because you are not running the <b>mysqld </b>daemon before launching the mysql client. The file /var/lib/mysql/mysql.sock will be automatically created upon running the first instance of mysql.

<b>To fix:</b>

First start the mysql daemon, then type mysql:

/etc/init.d/mysqld start

mysql

By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.

mysql&gt; USE mysql;

mysql&gt; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';

mysql&gt; FLUSH PRIVILEGES;

Once done, check by logging in:

mysql -u root -p

Enter Password: &lt;your new password&gt;

To create a new mysql user 'guest' with 'all privileges' on the database 'demo':

mysql &gt; create database demo

mysql &gt;GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;

mysql&gt; UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';

That's it! MySQL is ready! Don't forget to remember the root password as we might be using it with phpmyadmin.

Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

Don't forget to install <b>php-gd</b> (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.

Restart Apache to load php.

/etc/init.d/httpd restart

Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.

Then point your browser to http://ip.address/test.php.

That's it! You should see a php configuration file displaying all kind of paths and installed modules.

Closely observe the installed configuration on your server.

* PHP Paths (php.ini path)

* Apache paths and Loaded Modules (mod_security, mod_evasive if installed_

* PHP GD Library

* MySQL paths and other information

phpMyAdmin is a free web based MySQL database Administration Tool. Without phpMyAdmin it is almost impossible to mysql db operations in the command line. phpMyAdmin has become so convenient and it is absolutely sought by most webmasters to be present along with the mysql server.

yum install phpmyadmin

Point your browser to: http://ip.address/phpmyadmin.

You might encounter the following errors while configuring phpmyadmin.

<b>Forbidden </b>

You don't have permission to access /phpmyadmin/ on this server.

To fix:

Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all.

nano /etc/httpd/conf.d/phpmyadmin.conf

<b>Error</b>

The configuration file now needs a secret passphrase (blowfish_secret)

nano /usr/share/phpmyadmin/conf.inc.php

Look for a line and enter any password. <b>Just dont leave it empty!</b>

It worked for me using the above methods! 

Log into the phpmyadmin with the mysql root password we changed while installing the mysql database.

wget &lt;webmin rpm path&gt;

rpm - i webmin-1.410-1.noarch.rpm

That should be a pretty easy installation! Remember webmin uses port 10000 and should not be blocked by your firewall.

Point your browser to: http://ip.address:10000

You should see a webmin login. But we don't know the login and password yet! To set up the webmin password run the script below...

/usr/libexec/webmin/changepass.pl /etc/webmin admin &lt;newpasswd&gt;

Log in with the admin username and new webmin password!

To uninstall webmin, just run:

/etc/webmin/uninstall.sh

We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:

chkconfig httpd on

chkconfig mysqld on

Copyright © 2008 olddocks

All Rights Reserved.

簡單配置檔案:

apache的配置檔案是/etc/httpd/conf下

modules放在/usr/lib/httpd下

php的配置檔案在/etc/php.d/下 和/etc/php.ini

php的modules放在/usr/lib/php/modules下

7. 安裝Tomcat5

#yum -y install tomcat5 tomcat5-webapps tomcat5-admin-webapps

安裝Tomcat5安裝包和對應的依賴關系包

8. 啟動Tomcat5

#service tomcat5 start

#chkconfig tomcat5 on

9. 在浏覽器輸入http://你的IP:8080/,可以看到Apache SoftWare Foundation頁,如果看不到,請确認是否是防火牆問題

看到一個貓頭 ------------------&gt;tomcat5安裝成功

10. Apache與Tomcat整合

如果網站需同時整合Apache與Tomcat可以使用JK或者Proxy方式

使用VI編輯proxy_ajp.conf檔案

#vi /etc/httpd/conf.d/proxy_ajp.conf

輸入以下内容

ProxyPass /tomcat/ ajp://localhost:8009/

存儲檔案後,重新開機Apache

#service httpd restart

在浏覽器輸入http://你的IP/tomcat/,可以看到Apache SoftWare Foundation頁

As you may have guessed by now, this is the default Tomcat home page. It can be found on the local filesystem at:

$CATALINA_HOME/webapps/ROOT/index.jsp

這樣就可以解析 .jsp檔案。

本文轉自 pk2008 51CTO部落格,原文連結:http://blog.51cto.com/837244/901092

上一篇: ssh-keygen+rsync
下一篇: CUPS+SAMBA