Set up a web server that supports JSP + PHP on Linux

zhaozj2021-02-16  112

Set up a web server that supports JSP PHP on Linux

In recent years, Linux has the advantageous proportion of server market, in addition to the free and security of Linux, but also because of the application services on Linux. Most common services have a better solution on Linux. For the most wide web services applied on Intenet, Linux performance is better. No one has to say how many websites exactly on the Internet, but in many websites, the website developed by PHP and JSP will undoubtedly account for great market share. Let's introduce how to set up a web server that supports JSP PHP MySQL on Linux.

For web services, Apache is undoubtedly preferred. The database is used to use MySQL, which is also enough for general applications. Of course, LINUX can also install large databases such as Oracle, DB2, but they cost expensive. As for the development of language, JSP and PHP are undoubtedly the most widely used web development language of the current most mainstream and application. All of this software we can find from the following website:

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://mmmmysql.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.0.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

First, install mysql

MySQL installation 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-assembler - 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 modified /etc/ld.so.conf, in the end, add the following line:

/ usr / local / terry_yu / mysql / lib / mysql / lib? then do the following command:

# ldconfig

Start mysql with the following command

/ usr / local / terry_yu / mysql / bin / mysqld_safe &

Use the following command to modify the mysql root password:

/ usr / local / terry_yu / mysql / bin / mysqladmin -uroot password abcdefg

Use the following command to enter the mysql command line mode:

[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.15type 'help;' or '/ h' for help. Type '/ c' to clear the buffer.

Mysql> quit bye

The above information indicates that mysql has been successfully run.

Second, 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 / 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: $ ,_HOME / LIB: / usr / local / terry_yu / jdbc path = $ PATH: $ java_home / bin: $ java_home / jre / bin

Exit the current login environment, log in, so that the environment variable just set will take effect, then test the following command:

[root @ Terry root] # java -version java version "1.4.2_01" Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java Hotspot (TM) Client VM (Build 1.4.2_01-B06, Mixed mode)

I saw similar information that the JDK environment was already. In fact, in the above / etc / profile, we set more JDK's environment variables, but also set RESIN and JDBC environment variables, which are the settings necessary to install RESIN later. Third, install MySQL JDBC

MySQL's JDBC-related environment variables have been set in front, so the remaining only is installed by the following command:

# Tar? -Xzpvf mysql-connection-java-3.1.0-alpha.tar.gz # mv 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

Fourth, install Apache

http://apache.linuxForum.net/dist/httpd/apache_1.3.28.tar.gz

It should be noted that DSO support must be added when compiling Apache, if not, please join --enable-module = so option recompile 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 # Make Install checks the module to compile the Apache:

# / usr / local / terry_yu / apache / bin / httpd -l compiled-in modules: http_core.c mod_so.c

Seeing the above information indicates that apache supports the DSO mode. This allows the module of PHP and RESIN to be added in the way.

V. Install PHP

Installing PHP is relatively simple, we first 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

Editing the PHP profile is /usr/local/lib/php.ini, modifying the register_global variable to ON, default is OFF. Need to change it to ON. Otherwise, PHP will not directly read the phenomenon of POST or GET data.

Edit Apache's profile /usr/local/terry_yu/apache/conf/httpd.conf, plus 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 can then use a simple PHP file to test the installation of PHP, this simple PHP file contains the following line:

Save it as /usr/local/terry_yu/apache/htdocs/info.php, and then browse in your browser, if viewed to show the page with the "PHP Version 4.3.3" title, the integration PHP and Apache are successful. And in this page, you can see the PHP-related options, which should be related to MySQL sub-items, indicating that PHP has been built into Mysql. This means that the environment of PHP MySQL Apache has been successful, and next is to install RESIN to support the JSP environment.

Six. Installing Resin

http://www.caucho.com/download/resin-3.0.3.tar.gz

After downloading RESIN installation package, you should be able to run separately. The author declines it to the / usr / local / terry_yu directory

# Tar -Xzpvf resin-3.0.3.tar.gz # mv resin-3.0.3 / usr / local / terry_yu / # cd / usr / local / terry_yu / # ln -s resin-3.0.3 / resin

Start resin # /usr/local/terry_yu/resin/bin/httpd.sh start

If the relevant environment variables are set up when you install JDK, you can see RESIN's pages from http: // localhost: 8080 /, which means that individual RESIN is successful. Then, in order to integrate Resin and Apache, we need to recompile to generate mod_caucho to the Apache call. # cd / usr / local / terry_yu / resin # ./configure --with-apache = / usr / local / terry_yu / apache # make # make install

Modify /usr/local/terry_yu/resin/conf/resin.conf, approximately on Chapter 159 (the installed RESIN version is different, the content of the configuration file may vary), and "Document-Directory> is modified into its own apache) Document'TROOT value.

<% class.forname ("COM. Mysql.jdbc.driver "). NewinStance (); java.sql.connection conn; conn = java.sql.driverManager.getConnection (" JDBC: mysql: // localhost / mysql? user = root & password = Abcdefg ");%> Visit http: // localhost / testdb through the browser, if you see a blank page without any error message, it means that the JSP connection native mysql database is successful, and we have completed it. A web server that supports JSP PHP MySQL.

Note: All installed installations are done on Red Hat Linux9.0, and the software used is the latest version (Sep 2003).

This article describes how to set up a web server on Linux to support JSP and PHP, demonstrate the installation of mysql, JDK, JDBC, Apache, PHP, RESIN.

转载请注明原文地址:https://www.9cbs.com/read-8364.html

New Post(0)