Apache + Mysql + Php + GD + ZendOptimizer + JDK + Tomcat installation and configuration

Source: Internet
Author: User
Tags mysql command line
Apache + Mysql + Php + GD + ZendOptimizer + JDK + Tomcat installation and configuration-Linux Enterprise Application-Linux server application information. For more information, see the following. 1) install and configure Mysql (both Mysql 4.x. xx and Mysql 5.x. xx are supported)

Open and enter the Mysql compiling environment:
$ Tar xzvf mysql-x.x.xx.tar.gz
$ Cd mysql-x.x.xx/

Modify the maximum number of connections in the SQL/mysqld. cc configuration file required for compilation:
Search: & max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
Modify: & max_connections, 0, GET_ULONG, REQUIRED_ARG, 200, 1, 16384, 0, 1,

$ Groupadd mysql
$ Useradd-g mysql

(This may be required for Debian or Ubuntu systems)
Install the default missing curses/termcap Library:
$ Apt-cache search curses | grep lib
$ Apt-get install libncurses5-dev

$ Mkdir-p/opt/mysql/data
$ Mkdir-p/opt/mysql/var

$. /Configure -- prefix =/opt/mysql -- with-mysqld-user = mysql -- with-extra-charsets = all -- with-unix-socket-path =/opt/mysql/var /mysql. sock -- localstatedir =/opt/mysql/data -- with-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static -- enable-validator
Note: -- prefix =/opt/mysql to install the mysql-x.x.xx specified to the/opt/mysql directory;
-- With-extra-charsets = all supports multiple languages;
-- With-unix-socket-path =/opt/mysql/var/mysql. sock: Specifies the location and file name of the online socket file after the mysql server is started. This prevents mysql from being started;
-- With-mysqld-user = username: this allows the mysql server to enable the common username in the system to start the mysql server, so as to avoid the situation that the mysql server is dead but cannot be launched;
-- Localstatedir =/opt/mysql/data specifies the directory where database files are stored;

$ Make
$ Make install

After MySQL is installed, the configuration is complete;
$ Cp/opt/mysql/share/mysql/my-medium.cnf/etc/my. cnf

Note: copy the configuration file to the/etc directory to become my. cnf, you can choose the configuration file according to your needs (configuration file in the/opt/mysql/share/mysql/directory, there are my-huge.cnf my-medium.cnf my-large.cnf my-small.cnf these ).

Modify the file permissions and owner of various mysql systems to avoid errors during startup;
$ Chmod 755/opt/mysql/var/set the directory permission of/opt/mysql/var to 755
$ Chown-R mysql: mysql/opt/mysql/put the/opt/mysql directory under the mysql user

Create an authorization table for MySQL;
$/Opt/mysql/bin/mysql_install_db? User = mysql

Configure and start the Mysql service;
$/Opt/mysql/bin/mysqld_safe &
$ Cp/opt/mysql/share/mysql. server/etc/init. d/mysqld
$ Cd/opt/mysql/libexec
$ Cp mysqld. old
$ Strip mysqld
$ Ln-s/opt/mysql/bin/mysql/usr/bin/mysql
$ Ln-s/opt/mysql/bin/mysqladmin/usr/sbin/mysqladmin

$ Netstat-atln check whether port 3306 is enabled
$/Etc/init. d/mysqld restart if mysql is restarted successfully, the mysql installation is successful.
$ Mysqladmin-u root password 123456 set the mysql root password

$ Mysql-uroot? P123456 use the root user to access the mysql Command Line
Mysql> use mysql;
Mysql> delete from user where password = ""; delete an empty password account used for anonymous connection to the Local Machine
Mysql> flush privileges;
Mysql> quit;

Go to the rc2.d rc3.d rc4.d rc5.d directory in the/etc directory and create a soft link file for the auto-start service;
$ Ln-s ../init. d/mysqld S20mysql
Go to the rc0.d rc1.d rc6.d directory in the/etc directory and create a soft link file for shutting down and stopping services;
$ Ln-s ../init. d/mysqld K20mysql


2) install and configure Apache (Apache2.x. x)

Open and enter the Apache compiling environment:
$ Tar xzvf httpd-2.x.x.tar.gz
$ Cd httpd-2.x.x/

$. /Configure -- prefix =/opt/apache -- enable-so -- enable-rewrite -- enable-cgi -- with-config-file-path =/opt/apache/conf -- enable-track -vars -- with-mpm = worker
Note: -- prefix =/opt/apache indicates to install it in the/opt/apache directory;
-- Enable-cgi supports CGI;
-- With-config-file-path =/opt/apache/conf specifies to put the preparation file in the/opt/apache/conf directory;
-- The enable parameter tells the setting script that we need to start the so and rewrite modules. The so module is the apache core module that provides DSO support, while the rewrite module is the module that is designed to implement address rewriting, because the rewrite module requires DBM support, if it is not compiled into apache during the initial installation, you need to re-compile the entire apache later.

$ Make
$ Make install
Modify the configuration file/opt/apache/conf/httpd. conf:

ServerName 127.0.0.1: 80


DirectoryIndex index.html. var index.htm index. php


# If the AddEncoding directives abve are commented-out, then you
# Probably shoshould define those extensions to indicate media types:
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps

$ Cp/opt/apache/bin/apachectl/etc/init. d/apachectl
$ Ln-s/opt/apache/bin/apachectl/usr/bin/apachectl

Go to the rc2.d rc3.d rc4.d rc5.d directory in the/etc directory and create a soft link file for the auto-start service;
$ Ln-s ../init. d/apachectl S20apache
Go to the rc0.d rc1.d rc6.d directory in the/etc directory and create a soft link file for shutting down and stopping services;
$ Ln-s ../init. d/apachectl K20apache

$ Apachectl start
Enter the commercial IP address in the address bar of the browser. If "It works!" is displayed !" The installation is successful!

3) install Php and related common components (both Php4.x. x and Php5.x. x are supported)

Compile and install relevant GD library kits:
Zlib: Enter the decompressed zlib directory and execute the following command:
$./Configure
$ Make
$ Make install
Freetype: Enter the decompressed freetype directory and execute the following command:
$./Configure -- prefix =/usr/local/freetype
$ Make
$ Make install
Libpng: Enter the decompressed libpng directory and execute the following command:
$./Configure
$ Make
$ Make install
Jpeg-6b: Go to the unzipped jpeg-6b directory and execute the following command:
$ Mkdir-p/usr/local/jpeg/bin
$ Mkdir/usr/local/jpeg/lib
$ Mkdir/usr/local/jpeg/include
$ Mkdir-p/usr/local/jpeg/man/man1
$./Configure -- prefix =/usr/local/jpeg -- enable-shared -- enable-static
$ Make
$ Make install
GD Library: Enter the decompressed gd directory and execute the following command:
$. /Configure -- prefix =/usr/local/gd -- with-jpeg =/usr/local/jpeg -- with-freetype =/usr/local/freetype -- with-png --- zlib
$ Make
$ Make install

Open and enter the Php compiling environment:
$ Tar xzvf php-x.x.x.tar.gz
$ Cd php-x.x.x/

(This may be required for Debian or Ubuntu systems)
Install the lex component that is missing by default:
$ Apt-get install flex

Compile and install php:
$. /Configure -- prefix =/opt/php -- with-apxs2 =/opt/apache/bin/apxs -- with-gd =/usr/local/gd -- enable-gd- native-ttf -- with-jpeg-dir =/usr/local/jpeg -- with-png -- with-ttf -- with-zlib -- with-freetype-dir =/usr/local/ freetype -- enable-magic-quotes -- with-mysql =/opt/mysql -- with-mysql-sock =/opt/mysql/var/mysql. sock -- with-iconv -- with-mbstring -- enable-track-vars -- enable-force-cgi-redirect -- enable-ftp -- with-config-file-path = /opt/php/etc -- with-pear =/opt/php/pear -- enable-sockets -- with-mail -- with-xml

$ Make
$ Make install

$ Cp php-x.x.x/php. ini-dist/opt/ph/ etc/php. ini

Modify the configuration file/opt/php/etc/php. ini:
Register_globals = On

Then write the php test page info. php: The content is as follows:
Phpinfo ();
?>

Check the/opt/apache/conf/httpd. conf file to check whether the statement exists (if Php5 is installed ):
LoadModule php5_module modules/libphp5.so
If yes, apache has successfully loaded the php module;

$ Apachectl restart
Place info. php In the/opt/apache/htdocs directory;
$ Chmod 755 info. php
If the php information is displayed on this page in the browser, the installation is successful!
NOTE: If SELinux is enabled for FC or RedHat, a permission error is prompted and Php cannot work properly. If SELinux is disabled, restart the system to solve the problem.


4) install and configure ZendOptimizer (available in all versions)
$ Tar xzvf ZendOptimizer-x.x.x-linux-x-i386.tar.gz
$ Cd ZendOptimizer-x.x.x/
$./Install. sh
Follow the prompts In the Installation Wizard to complete the installation and configuration process;

Now, the LAMP environment has been installed. If you do not need the Tomcat service, it will end here.

5) install and configure JDK (j2sdk-1.4.2.xx version is available)

$ Chmod a + x j2sdk-1_4_2_09-linux-i586.bin (version 1.4.2 _ 09 installed in this article)
$./J2sdk-1_4_2_09-linux-i586.bin
After installation, the j2sdk1.4.2 _ 09 folder will be generated, and the j2sdk1.4.2 _ 09 folder will be moved (or copied) to the JDK location you want to store (in this article,/opt/j2sdk1.4.2 _ 09 /);
Next, edit the/etc/profile file and add the JDK environment variable. Add the following content to the end of the file:

$ Vi/etc/profile

Export JAVA_HOME =/opt/j2sdk1.4.2 _ 09
Export CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export PATH = $ PATH: $ JAVA_HOME/bin
Export JRE_HOME = $ JAVA_HOME/jre

$ Source/etc/profile
In this way, the content of the configuration file takes effect immediately;

$ Set
Here you can see all the current environment variables;

$ Java? Version
If the JDK configuration is correct, the corresponding JDK version will appear when you run the above command.


6) install and configure Tomcat and related components (jakarta-tomcat-5.x.xx version is available)
$ Tar xzfv jakarta-tomcat-5.0.28.tar.gz (the version installed in this article is: jakarta-tomcat-5.0.28)

$ Cp-rf jakarta-tomcat-5.0.28/opt/tomcat
$ Cd/opt/tomcat/

Now let's test whether tomcat is successfully installed:

$./Bin/startup. sh start the tomcat Service
Visit http: // 127.0.0.1: 8080/to check whether the default page of tomcat is displayed. It indicates that the tomcat service is running.

$./Bin/shutdown. sh stop tomcat Service
Observe whether an error is reported when the service is stopped.
Start to install the jakarta-tomcat-connectors-jk2, used to integrate apache and tomcat, compiled into the mod_jk2.so module is loaded by apache, you can not own the request forwarded to tomcat:
$ Tar xzfv jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz

$ Cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/

$./Configure -- with-apxs2 =/home/www/apache/bin/apxs
$ Make

$ Cd ../build/jk2/apache2/
$/Opt/apache/bin/apxs-n jk2-I mod_jk2.so (add mod_jk2.so to modules of apache2)

The above completes the installation of Tomcat and Connectors, and then the integration with Apache.

Integration of Tomcat and Apache:
$ Cd/opt/apache/conf/

Vi httpd. conf

Edit the configuration file and add it to this module. Save and exit;
LoadModule jk2_module modules/mod_jk2.so

Create a file workers2.properties in this directory.
$ Vi workers2.properties

[Channel. socket: localhost: 8009]
Port = 8009
Host = localhost
[Ajp13: localhost: 8009]
Channel = channel. socket: localhost: 8009
[Uri:/*. jsp]
Worker = ajp13: localhost: 8009
[Uri:/examples/*. jsp]
Worker = ajp13: localhost: 8009

$ Cd/opt/tomcat/conf/

Vi server. xml
Find In Item, modify the relevant parameters as follows, save and exit;


$/Opt/tomcat/bin/startup. sh
$ Apachectl restart
Restart Apache and Tomcat to view the integrated results.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.