In recent years, the proportion of Linux in the server market has increased. In addition to the free and secure nature of Linux, the Linux application services have become increasingly abundant. Most common services have good solutions on Linux. For the most widely used Web Services on Intenet, Linux has a better performance. No one can tell the exact number of websites on the Internet, but among the many websites, websites developed using PHP and JSP undoubtedly occupy a huge market share. The following describes how to set up a Web server that supports jsp php MySQL on Linux.
Apache is undoubtedly the first choice for Web Services. MySQL is used for databases, which is enough for general applications. Of course, large databases such as oracle and DB2 can be installed in Linux, but they are expensive. JSP and PHP are the most popular and widely used web development languages. All of these software can be found on the following websites:
Resin: http://www.caucho.com/
JDK: http://java.sun.com/
Apache: http://www.apache.org
MySQL: http://www.mysql.com
PHP: http://www.php.net
MM. MySQL: http://mmmysql.sourceforge.net/
Download the corresponding software from the above website. The software downloaded by the author is as follows:
Mysql-4.0.15.tar.gz
Apache_1.3.28.tar.gz
Php-4.3.3.tar.gz
Resin-3.0.3.tar.gz
Mysql-connector-java-3.1.0-alpha.tar.gz
J2sdk-1_4_2_01-linux-i586.bin
1. Install MySQL
The installation of MySQL is relatively simple, but the compilation process may be a bit long. The specific steps are as follows:
# Tar-xzpvf mysql-4.0.15.tar.gz
# Adduser-s/bin/false mysql
#./Configure -- prefix =/usr/local/terry_yu/mysql -- enable-Guest er
-- With-innodb -- with-charset = gb2312
# Make
# Make install
#/Usr/local/terry_yu/mysql/bin/mysql_install_db
# Chown-R root/usr/local/terry_yu/mysql/
# Chown-R mysql/usr/local/terry_yu/mysql/var
# Chgrp-R mysql/usr/local/terry_yu/mysql/
#/Usr/local/terry_yu/mysql/bin/mysql_install_db
Modify/etc/ld. so. conf and add the following line at the end:
/Usr/local/terry_yu/mysql/lib
Run the following command:
# Ldconfig
Run the following command to start MySQL
/Usr/local/terry_yu/mysql/bin/mysqld_safe &
Run the following command to modify the MySQL root Password:
/Usr/local/terry_yu/mysql/bin/mysqladmin-uroot password abcdefg
Run the following command to access the MySQL command line:
[Root @ terry root] #/usr/local/terry_yu/mysql/bin/mysql-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1 to server version: 4.0.15
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql> quit
Bye
The above information indicates that MySQL has been successfully run.
Ii. Install JDK
# Chmod 755 j2sdk-1_4_2_01-linux-i586.bin
#./J2sdk-1_4_2_01-linux-i586.bin
# Mv j2sdk1.4.2 _ 01 // usr/local/terry_yu/
# Cd/usr/local/terry_yu/
# Ln-s j2sdk1.4.2 _ 01/jdk
# Ln-s jdk/jre
# Vi/etc/profile
JAVA_HOME =/usr/local/terry_yu/jdk
RESIN_HOME =/usr/local/terry_yu/resin
CLASSPATH =.../$ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ RESIN_HOME/lib:/usr/local/terry_yu/jdbc
PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin
Log out of the current logon environment and log on again. Then, the environment variable you just set will take effect. Then, run the following command to test it:
[Root @ terry root] # java-version
Java version "1.4.2 _ 01"
JavaTM) 2 Runtime Environment, Standard Edition build 1.4.2 _ 01-b06)
Java HotSpotTM) Client VM build 1.4.2 _ 01-b06, mixed mode)
If you see similar information, the JDK environment is ready. In fact, in the above/etc/profile, we not only set the JDK environment variables, but also set the environment variables for Resin and JDBC. These are all necessary settings for installing Resin later.
Iii. Install MySQL JDBC
The environment variables related to MySQL JDBC have been set before, so the rest is to install by the following command:
# Tar-xzpvf mysql-connector-java-3.1.0-alpha.tar.gz
# Music mysql-connector-java-3.1.0-alpha/usr/local/terry_yu/
# Cd/usr/local/terry_yu/
# Ln-s mysql-connector-java-3.1.0-alpha/jdbc
4. install Apache
Http://apache.linuxforum.net/dist/httpd/apache_1.3.28.tar.gz
Note that DSO support must be added during apache compilation. If not, add the -- enable-module = so option to re-compile apache.
# Tar-xzpvf apache_1.3.28.tar.gz
# Cd apache_1.3.28/
#./Configure -- prefix =/usr/local/terry_yu/apache -- enable-module = most
-- Enable-shared = max
# Make
# Make install
View the modules compiled into apache:
#/Usr/local/terry_yu/apache/bin/httpd-l
Compiled-in modules:
Http_core.c
Mod_so.c
The above information indicates that apache supports DSO. In this way, you can use DSO to add the php and resin modules.
5. install PHP
Installing PHP is relatively simple. We should install PHP first.
# Tar-xzpvf php-4.3.3.tar.gz
# Cd php-4.3.3/
#./Configure -- with-mysql =/usr/local/terry_yu/mysql
-- With-apxs =/usr/local/terry_yu/apache/bin/apxs
# Make
# Make install
# Cp php. ini-dist/usr/local/lib/php. ini
Edit the PHP configuration file/usr/local/lib/php. ini and change the register_globals variable to On. The default value is Off. You need to change it to On. Otherwise, php cannot directly read post or get data.
Edit the Apache configuration file/usr/local/terry_yu/apache/conf/httpd. conf and add the following line at the end of the file:
AddType application/x-httpd-php. php. php3
Start apache:
#/Usr/local/terry_yu/apache/bin/apachectl start
Then, you can use a simple PHP file to test PHP installation. This simple PHP file contains the following lines:
<? Phpinfo);?>
Save it as/usr/local/terry_yu/apache/htdocs/info. php, And Then browse in the browser. If the page displays "PHP Version4.3.3", it indicates that PHP and Apache are integrated successfully. In addition, you can see the PHP-related options on this page, which should have sub-items about MySQL, which indicates that PHP has built-in support for MySQL. This indicates that the PHP MySQL Apache environment has been successfully installed. Next, install Resin to support the JSP environment.
6. install Resin
Http://www.caucho.com/download/resin-3.0.3.tar.gz