Configuration tutorials for Nginx+apache+mysql+php+tomcat in CentOS (PHP, JAVA support)

Source: Internet
Author: User
Tags chmod gettext openssl php file php mysql net domain phpmyadmin zend

First look at the CENTOS6.4+APACHE-2.2.22+MYSQL-5.1.63+PHP-5.2.17+PHPMYADMIN-3.4.10.2+ZENDDEBUG environment installation

Lamp installation Notes (Centos6.4+apache-2.2.22+mysql-5.1.63+php-5.2.17+phpmyadmin-3.4.10.2+zenddebug)

The code is as follows Copy Code

RPM-E httpd

RPM-E MySQL

Rpm-e PHP

Yum-y Remove httpd php mysql-server mysql php-mysql 

Setenforce 0

Yum-y Install GCC gcc-c++  Make Automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel   Pcre-devel libtool-libs freetype-devel gd zlib-devel file Bison patch Mlocate Flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel wget&nbsp ;unzip 

Wget-c http://archive.apache.org/dist/httpd/httpd-2.2.22.tar.gz

Wget-c http://dl.mysql.cn/mysql5/5.1/mysql-5.1.63.tar.gz

Wget-c http://iweb.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.10.2/phpMyAdmin-3.4.10.2-all-languages.tar.gz

Wget-c Http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror

Tar xzf httpd-2.2.22.tar.gz

Tar xzf mysql-5.1.63.tar.gz

Tar xzf php-5.2.17.tar.gz

Tar xzf phpmyadmin-3.4.10.2-all-languages.tar.gz

cd/tmp/httpd-2.2.22

./configure--prefix=/usr/local/apache--with-included-apr--enable-so--enable-deflate=shared--enable-expires= shared  --enable-headers=shared--enable-rewrite=shared--enable-static-support

Make

Make install

CP build/rpm/httpd.init/etc/init.d/httpd//Use init script management httpd

chmod 755/etc/init.d/httpd//Increase execution permissions

Chkconfig--add httpd  Adding httpd to service items

chkconfig  httpd on   //Set boot up

ln-fs/usr/local/apache//etc/httpd

Ln-fs/usr/local/apache/bin/httpd/usr/sbin/httpd

Ln-fs/usr/local/apache/bin/apachectl/usr/sbin/apachectl

LN-FS/USR/LOCAL/APACHE/LOGS/VAR/LOG/HTTPD//Set up soft links to fit init scripts

Groupadd MySQL

useradd-g MySQL MySQL

cd/tmp/mysql-5.1.63

./configure--prefix=/usr/local/mysql/--localstatedir=/usr/local/mysql/data--without-debug-- With-unix-socket-path=/tmp/mysql.sock--with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static-- Enable-assembler--with-extra-charsets=gbk,gb2312,utf8--with-pthread

Make

Make install

CP support-files/my-medium.cnf/etc/my.cnf//Replication Configuration folder my.cnf

/usr/local/mysql/bin/mysql_install_db--user=mysql  Initializing the database

Chown-r Root.mysql/usr/local/mysql

Chown-r mysql/usr/local/mysql/data 

cp/tmp/mysql-5.1.63/support-files/mysql.server/etc/rc.d/init.d/mysqld  Init startup script

Chown root.root/etc/rc.d/init.d/mysqld 

chmod 755/etc/rc.d/init.d/mysqld

Chkconfig--add mysqld

chkconfig  Mysqld on

Ln-s/usr/local/mysql/bin/mysql/usr/bin

Ln-s/usr/local/mysql/bin/mysqladmin/usr/bin

Service mysqld Start

/usr/local/mysql/bin/mysqladmin-u root password ' new password '    //Set Root password

Installing PHP

Cd/tmp

wget http://superb-dca2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

wget http://superb-dca2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

wget http://superb-sea2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

Tar xzf libmcrypt-2.5.8.tar.gz

Tar xzf mhash-0.9.9.9.tar.gz

Tar xzf mcrypt-2.6.8.tar.gz

Install Libmcrypt

cd/tmp/libmcrypt-2.5.8

./configure--PREFIX=/USR

Make && make install

Install Libmcrypt

cd/tmp/mhash-0.9.9.9

./configure--PREFIX=/USR

Make && make install

Install MCrypt

/sbin/ldconfig//Search for a shared dynamic link library

cd/tmp/mcrypt-2.6.8

./configure

Make && make install

Resolve errors that may occur:

If Configure fails try--with-jpeg-dir=<dir>

Configure:error:libpng. (A|SO) not found.

Solve:

Yum Install libpng Libpng-devel

Ln-s/usr/lib64/libjpeg.so/usr/lib/

Ln-s/usr/lib64/libpng.so/usr/lib/

Resolve Libiconv errors that may occur

Cd/tmp

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

Tar xzf libiconv-1.14.tar.gz

CD libiconv-1.14

./configure--prefix=/usr/local/libiconv

Make && make install

cd/tmp/php-5.2.17

./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/etc-- WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl--enable-ftp- -WITH-GD--enable-gd-native-ttf--with-gettext--with-mhash--enable-mbstring--with-mcrypt-- Enable-zip--with-iconv=/usr/local/libiconv--with-mysql=/usr/local/mysql--without-pear

Make

Make install

CP Php.ini-dist/usr/local/php/etc/php.ini//Replication configuration file PHP.ini

To modify the Apache configuration file:

To add a PHP file type resolution to the/etc/httpd/conf/httpd.conf file:

Vi/etc/httpd/conf/httpd.conf

Add to

AddType application/x-httpd-php. php. Phtml. Inc.

AddType Application/x-httpd-php-source. Phps

Found it:

ServerName www.example.com:80

Modified to:

ServerName localhost:80

Service httpd Restart &nbsp;//restart httpd

Install ZendOptimizer-3.3.9

64 digits: http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

32 digits: http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

Cd/tmp

wget&nbsp; Http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

Tar xzf zendoptimizer-3.3.9-linux-glibc23-i386.tar.gz

cd/tmp/zendoptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/

Mkdir-p/usr/local/zend/lib/

CP Zendoptimizer.so/usr/local/zend/lib

Load Zendoptimizer, build/etc/php.d/zend.ini file, add the following code to load:

[Zend]

Zend_optimizer.optimization_level=15

Zend_extension=/usr/local/zend/lib/zendoptimizer.so

Service httpd Restart

Install eAccelerator-0.9.6.1

Cd/tmp

wget Http://jaist.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip

Unzip Eaccelerator-0.9.6.1.zip

CD eaccelerator-0.9.6.1

Export php_prefix= "/usr/local/php"

$PHP _prefix/bin/phpize

./configure-enable-eaccelerator=shared-with-php-config= $PHP _prefix/bin/php-config

Make && make install

Cd/tmp

mkdir Eaccelerator

chmod 0777 Eaccelerator

PHP Zenddebugger failed to load

viewing information with Php-v

[Root@e modules]# Php-v

Failed Loading/usr/lib64/php/modules/zenddebugger.so:libssl.so.0.9.8:cannot Open Shared object file:no such file or di Rectory

Failed loading/usr/local/zend/lib/zendoptimizer.so:/usr/local/zend/lib/zendoptimizer.so:undefined symbol:zend_ Throw_exception_internal

Failed Loading/usr/lib64/php/modules/zenddebugger.so:libssl.so.0.9.8:cannot Open Shared object file:no such file or di Rectory

Warning:directive ' register_long_arrays ' is deprecated in PHP 5.3 and greater into Unknown on line 0

Warning:directive ' MAGIC_QUOTES_GPC ' is deprecated in PHP 5.3 and greater into Unknown on line 0

PHP 5.3.3 (CLI) (Built:nov 22 2013 10:59:29)

Copyright (c) 1997-2010 the PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Reason: Because the latest Linux distributions &nbsp;libssl&nbsp; and &nbsp;libcrypto&nbsp; have been upgraded to 1.0.0

Solution: Just create the corresponding soft link can

[Root@e modules]# ll/usr/lib64/libssl*

-rwxr-xr-x. 1 root root 221568 2?? 2013/usr/lib64/libssl3.so

lrwxrwxrwx. 1 root root 16 11?? 19:31/usr/lib64/libssl.so-> libssl.so.1.0.1e

lrwxrwxrwx. 1 root root 16 11?? 19:31/usr/lib64/libssl.so.10-> libssl.so.1.0.1e

-rwxr-xr-x. 1 root root 436984 12?? 4 2013/usr/lib64/libssl.so.1.0.1e

To establish a soft connection:

Ln-s/usr/lib64/libssl.so.1.0.1e/usr/lib64/libssl.so.0.9.8

[Root@e modules]# ll/usr/lib64/libcrypto*

lrwxrwxrwx. 1 root root 19 11?? 19:31/usr/lib64/libcrypto.so-> libcrypto.so.1.0.1e

lrwxrwxrwx. 1 root root 19 11?? 19:31/usr/lib64/libcrypto.so.10-> libcrypto.so.1.0.1e

-rwxr-xr-x. 1 root root 1946880 12?? 4 2013/usr/lib64/libcrypto.so.1.0.1e

To establish a soft connection:

Ln-s/usr/lib64/libcrypto.so.1.0.1e/usr/lib64/libcrypto.so.0.9.8

Then see how to install Jdk+tomcat6 in a lnamp environment so that the same server supports both PHP and the Java language.
The server system and the software versions are as follows:

The code is as follows Copy Code

[Root@e ~]# Uname-a
Linux e.centos6.4 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 00:31:26 UTC 2013 x86_64 x86_64 x86_64 gnu/linux
[Root@e ~]#/www/wdlinux/nginx/sbin/nginx-v
Nginx version:nginx/1.2.9
[Root@e ~]#/www/wdlinux/httpd-2.2.24/bin/httpd-v
Server version:apache/2.2.24 (Unix)
Server BUILT:OCT 30 2014 00:17:07
[Root@e ~]# rpm-qa |grep MySQL
Mysql-libs-5.1.66-2.el6_3.x86_64
[Root@e ~]#/www/wdlinux/php/bin/php-v
Cannot load Zend Extension manager-it was built to configuration 1.2.0, whereas running engine is api220090626,nts
PHP 5.3.27 (CLI) (built:oct 30 2014 00:30:02)
Copyright (c) 1997-2013 the PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies


To begin installing the JDK:

List the JDK installation packages available for the Yum Library

The code is as follows Copy Code

[Root@e ~]# yum-y list java*
Loaded Plugins:fastestmirror
Loading mirror speeds from cached hostfile
* base:mirror.bit.edu.cn
* extras:mirror.bit.edu.cn
* rpmforge:mirrors.neusoft.edu.cn
* updates:mirrors.neusoft.edu.cn
Base | 3.7 KB 00:00
Extras | 3.3 KB 00:00
Rpmforge | 1.9 KB 00:00
Updates | 3.4 KB 00:00
updates/primary_db | 171 KB 00:00
Available Packages
java-1.5.0-gcj.x86_64 1.5.0.0-29.1.EL6 Base
java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.EL6 Base
java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.EL6 Base
java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.EL6 Base
java-1.6.0-openjdk.x86_64 1:1.6.0.33-1.13.5.0.el6_6 Updates
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.33-1.13.5.0.el6_6 Updates
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.33-1.13.5.0.el6_6 Updates
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.33-1.13.5.0.el6_6 Updates
java-1.6.0-openjdk-src.x86_64 1:1.6.0.33-1.13.5.0.el6_6 Updates
java-1.7.0-openjdk.x86_64 1:1.7.0.71-2.5.3.1.el6 Updates
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.71-2.5.3.1.el6 Updates
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el6 Updates
Java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.71-2.5.3.1.el6 Updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.71-2.5.3.1.el6 Updates
java-1.8.0-openjdk.x86_64 1.8.0.25-1.b17.el6 Updates
java-1.8.0-openjdk-demo.x86_64 1.8.0.25-1.b17.el6 Updates
java-1.8.0-openjdk-devel.x86_64 1.8.0.25-1.b17.el6 Updates
java-1.8.0-openjdk-headless.x86_64 1.8.0.25-1.b17.el6 Updates
Java-1.8.0-openjdk-javadoc.noarch 1.8.0.25-1.b17.el6 Updates
java-1.8.0-openjdk-src.x86_64 1.8.0.25-1.b17.el6 Updates
java_cup.x86_64 1:0.10K-5.EL6 Base
java_cup-javadoc.x86_64 1:0.10K-5.EL6 Base
java_cup-manual.x86_64 1:0.10K-5.EL6 Base
javacc.x86_64 4.1-0.5.EL6 Base
javacc-demo.x86_64 4.1-0.5.EL6 Base
javacc-manual.x86_64 4.1-0.5.EL6 Base
Javassist.noarch 3.9.0-6.EL6 Base
Javassist-javadoc.noarch 3.9.0-6.EL6 Base


Select jdk1.6 Installation

The code is as follows Copy Code

[root@e ~]# yum-y Install java-1.6.0-openjdk*

Other versions please modify the corresponding version number of the installation
Detect if the installation was successful

The code is as follows Copy Code

[Root@e ~]# Java-version
Java Version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)
OpenJDK 64-bit Server VM (build 23.25-b01, Mixed mode)


Install Tomcat6


[Root@e ~]# yum install Tomcat6 Tomcat6-webapps
Installation started successfully
[Root@e ~]# Service Tomcat6 start
Other commands: Service Tomcat6 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}
Launch successful, Access test: http://ip:8080


Configure Nginx and Tomcat so that it does not add a port number and can be accessed directly through the domain name
First, to increase the resolution, so that the domain name to the host IP, local can be directly changed host implementation

Parse Normal
No 8080 port access

Add 8080 port access

Next, modify the Nginx and Tomcat configuration so that it can access Tomcat's webservice without a port number

The code is as follows Copy Code
[Root@e ~]# cd/www/wdlinux/nginx/conf/vhost/
[Root@e ~]# VI 111cn.net.conf
Add the following content
server {
Listen 80;
server_name www.111cn.net 111cn.net;
#root/www/web/master_myweb_com/public_html;
Index index.html index.jsp index.htm;
Error_page 400/errpage/400.html;
Error_page 403/errpage/403.html;
Error_page 404/errpage/404.html;
Error_page 405/errpage/405.html;
Location ~. jsp$ {
Proxy_pass http://127.0.0.1:8080;
Include naproxy.conf;
}
Location/{
Try_files $uri @tomcat;
}
Location @tomcat {
Proxy_pass http://127.0.0.1:8080;
Include naproxy.conf;
}
Access_log/www/web_logs/myweb_com_access.log Wwwlogs;
Error_log/www/web_logs/myweb_com_error.log;
}
Reload the Nginx configuration file or reboot the Nginx
[Root@e vhost]# Service Nginxd Reload
Nginx:the configuration file/www/wdlinux/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/www/wdlinux/nginx/conf/nginx.conf Test is successful

Access test without port number:
9
This nginx has successfully delegated the request from the 111cn.net domain name to port 8080
If you need to configure multiple domain names, you will also need to modify the Tomcat virtual host configuration file
Default profile path:/etc/tomcat6/
Default Project path:/var/lib/tomcat6/webapps/
Tomcat default point to/var/lib/tomcat6/webapps/root directory
Create a new project directory, where you copy the root project directly and modify it

  code is as follows copy code
[root@e webapps]# pwd
/var/lib/tomcat6/webapps
[root@e webapps]# chown-r R Oot 111cn.net
Modify permissions so that new project permissions and default project permissions are consistent
[Root@e webapps]# chgrp-r Tomcat 111cn.net
[root@e webapps]# ll
Total Usage 2 4
Drwxrwxr-x 5 root tomcat 4096 October 22:06 examples
Drwxrwxr-x 5 root tomcat 4096 October 22:06 Host-manager drwxrwxr-x 5 root tomcat 4096 October 22:06 manager
Drwxr-xr-x 3 root tomcat 4096 October 22:48 111cn.net
drwxr Wxr-x 3 root tomcat 4096 October 22:06 root
drwxrwxr-x 5 root tomcat 4096 October 22:06 sample
[Root@e 111cn.net]# CD 111cn.net/
[root@e 111cn.net]# rm-f index.html
[root@e 111cn.net]# vi index.jsp

Write: WebService is Tomcat
Do not forget to delete the root item or to kill it, otherwise the new project will not take effect
[Root@e webapps]# MV Root/root. Bak


Modifying Tomcat Virtual Host configuration

[Root@e 111cn.net]# Vi/etc/tomcat6/server.xml
After the bottom <Host></Host> tag, add the following

The code is as follows Copy Code
<!--111cn.net host config-->
Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "/" reloadable= "true" docbase= "111cn.net"/>
<Alias>111cn.net</Alias>
<!--Singlesignon valve, share authentication between Web applications
Documentation at:/docs/config/valve.html-->
<!--
<valve classname= "Org.apache.catalina.authenticator.SingleSignOn"/>
-->
<!--Access log processes all example.
Documentation at:/docs/config/valve.html-->
<!--
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "Logs"
Prefix= "Localhost_access_log." suffix= ". txt" pattern= "common" resolvehosts= "false"/>
-->
</Host>
Reboot Tomcat, test http://111cn.net
[Root@e 111cn.net]# Service Tomcat6 restart
11
Succes
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.