UBUNTU-12.04.2-DESKTOP-AMD64 Install integrated Nginx + PHP + mysql + phpmyadmin + tomcat

Source: Internet
Author: User
Tags fpm get ip install php php script save file

Recently need to do JSP project, deployed in Ubuntu, the weekend time to configure the Nginx + PHP + mysql + phpmyadmin + tomcat environment, from the Windows C # turn around, how much some do not adapt, estimated to go the whole stack direction. By the way, the introduction of the configuration method, complete under the console. 1.1 Common
    • Start Terminal

Ctrl+alt+t

    • Using the root user

Sudo–sh

    • View process

Linux command ps aux|grep xxx

    • Soft connection

Ln-s Source Address Destination Address

For example, the Linux file system Rootfs_dir Soft link to the/home/jyg/directory

Ln-s/opt/linux/rootfs_dir/home/jyg/rootfs_dir can do it.

    • Find Files

Find/-name [filename]

    • Installation based on the Debian Software Library

Apt-get

1.2 Install Java
    • OpenJDK 1.6.0

sudo apt-get install OPENJDK-6-JDK

sudo apt-get install OPENJDK-7-JDK

sudo update-alternatives--config java

sudo update-alternatives--config javac

sudo update-alternatives--config javaws

sudo vi/etc/environment

#Add following

Java_home= "/usr/lib/jvm/java-1.6.0-openjdk-i386"

Test:

Source/etc/environment

Echo $JAVA _home

Uninstall

sudo apt-get remove openjdk-6-jdk

    • Oracle JDK 1.7:

The easy-to-install the last JKD1.7

--sudo apt-get install python-software-properties

sudo add-apt-repository Ppa:webupd8team/java

sudo apt-get update

sudo apt-get install Oracle-java7-installer

Uninstall

sudo apt-get remove Oracle-java7-installer

    • Oralce JDK 1.7.0_03 (the live environment specifies the JDK version as required by the company)

Download JDK

Http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz

(You get the permission by access the page:http://www.oracle.com/technetwork/java/javase/downloads/ jdk7-downloads-1637583.html)

CD ~/downloads

TAR–ZXCF jdk-7u3-linux-x64.tar.gz

#you'll see the folder jdk1.7.0_03, for the same which live, change the folder name to JDK 1.7.0

MV Jdk1.7.0_03 jdk1.7.0

sudo mkdir–p–m ug+rw/usr/lib/jvm/jdk1.7.0

Sodu MV jdk1.7.0/usr/lib/jvm/

sudo update-alternatives--install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1. 1.7.0/bin/java "1

sudo update-alternatives--install "/usr/bin/javac" "Javac" "/usr/lib/jvm/jdk1. 1.7.0/bin/javac "1

sudo update-alternatives--install "/usr/bin/javaws" "Javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1

sudo update-alternatives--config java

sudo update-alternatives--config javac//

sudo update-alternatives--config javaws

sudo vi/etc/environment

#Add following

Java_home= "/usr/lib/jvm/jdk1.7.0"

Test:

Source/etc/environment

Echo $JAVA _home

Notice:if want to install the other version JDK, please see the install other JDK

1.3 Install Nginx

sudo apt-get install Nginx

Useful Command about Nginx.

Start Nginx:sudo/etc/init.d/nginx start; sudo service nginx start

Test:browser the Location:http://localhost; If browser show "Welcome to nginx!", you have installed nginx successfully;

Shutdown Nginx:sudo/etc/init.d/nginx stop;

Restart Nginx:sudo/etc/init.d/nginx Restart;

**you can run the following command to reveal your virtual server s IP address.

Ifconfig eth0 | grep inet | awk ' {print $} '

When your visit your IP address page in your browser, you'll see the words, "Welcome to Nginx"

You can see a screenshot of the Utilitarian Nginx welcome page here

To ensure that nginx'll be-after reboots, it's best to add it to the startup. Type this command into terminal:

UPDATE-RC.D Nginx Defaults

1.4 Install PHP
    • Installation

sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql

PHP5-FPM: One of the ways of fitting with Nginx, the other one is: spawn-fcgi;

Php5-mysql: Access MySQL;

    • Modify Nginx Configuration

sudo vi/etc/nginx/sites-available/default

Modify the row of Index to: "Index index.html index.htm index.php;"

Remove the following comment to support the PHP script:

Location ~ \.php$ {

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Include Fastcgi_params;

}

    • Test

Nginx Default Site Directory: cd/usr/share/nginx/www

echo "<?php phpinfo ();? > "> test.php

Start Nginx:

Sudo/etc/init.d/nginx start

Visit: http://localhost/test.php

The PHP details appear and the configuration is successful.

Close Nginx

Sudo/etc/init.d/nginx stop

1.5 Install Mysql
    • Installation

sudo apt-get install Mysql-server

The user name secret is required during installation. [Mysqluser]/[MYSQLPW]

    • Test

Mysql–u [Mysqluser]–p

Enter the MySQL console.

1.6 Install PhpmyAdmin
    • Download phpmyadmin-4.2.7-all-languages.tar.gz (this requires manual download, with Debian installed directly, and Nginx integration will be more troublesome)

Website Direct download: http://www.phpmyadmin.net/home_page/downloads.php

Terminal Download

wget http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-4.2.7-all-languages.tar.gz

Save file to/var/lib:sudo MV Phpmyadmin-4.2.7-all-languages.tar.gz/var/lib/phpmyadmin

    • Download Unzip:

Cd/var/lib/phpmyadmin

sudo tar zxvf phpmyadmin-4.2.7-all-languages.tar.gz

    • To create a soft connection:

Ln–s/var/lib/phpmyadmin/phpmyadmin-4.2.7-all-languages/usr/share/nginx/www/phpmyadmin

    • Test

Visit: Http://localhost/phpmyadmin

The landing page appears, log in with MySQL user name density.

1.7 Install Tomcat 7

sudo apt-get install tomcat7 tomcat7-docs tomcat7-examples tomcat7-admin

Choose username and password to manage Tomcat and add To/etc/tomcat7/tomcat-users.xml file in the below format.

<role rolename= "Manager-gui"/>

<role rolename= "Admin-gui"/>

<user username= "[Tomactadmin]" password= "[TOMCATPW]" roles= "Manager-gui,admin-gui"/>

This code must is within this < Tomcat-users > ... </tomcat-users > Tags

Now restart the service.

SUDO/ETC/INIT.D/TOMCAT7 restart

    • Integration with Nginx
      • Must make sure stop TOMCAT7 and Nginx first: (There are a lot of strange problems if there is no stop Tomcat 7)

SUDO/ETC/INIT.D/TOMCAT7 stop

Sudo/etc/init.d/nginx stop

      • Modify the Tomcat configuration

sudo vi/etc/tomcat7/server.xml

Change

      • Modify Nginx under Proxy_params

sudo vi/etc/nginx/proxy_params

Add to:

Client_max_body_size 10m;

Client_body_buffer_size 128k;

Proxy_connect_timeout 90;

Proxy_send_timeout 90;

Proxy_read_timeout 90;

Proxy_buffer_size 4k;

Proxy_buffers 4 32k;

Proxy_busy_buffers_size 64k;

Proxy_temp_file_write_size 64k;

      • To modify the NGINGX configuration:

sudo vi/etc/nginx/sites-available/default

Modify index Behavior: "Index index.html index.htm index.php index.jsp;"

In "Location ~ \.php${...}" The PHP configuration section adds:

Location ~ \.jsp$ {

Index index.jsp;

Proxy_pass http://localhost:8080;

Include Proxy_params;

}

      • Test

New catalog: sudo mkdir/usr/share/nginx/www/test

New JSP file: sudo vi/usr/share/nginx/www/test/test.jsp

Input:

<HTML>

<BODY>

<%

Out.println ("IP:");

Out.println (Request.getheader ("x-forwarded-for"));

%>

</BODY>

</HTML>

Start TOMCAT:SUDO/ETC/INIT.D/TOMCAT7 Start

Start Nginx:sudo/etc/init.d/nginx Start

Visit: http://localhost/test/test.jsp

See Tomcat Log if you have questions:

Cat/var/log/tomcat7catalina.out |more

The "ip:192.168.11.22" configuration appears successfully.

Description, because the function of Nginx Proxy is used here, so to get Ip;request.getremotehost () with Request.getheader ("X-forwarded-for") will be the proxy IP, namely: 127.0.0.1.

1.8 Install Eclipse

sudo apt-get install Eclipse-platform

sudo apt-get install ECLIPSE-JDK

--need reconfig java VM

sudo update-alternatives--config java

sudo update-alternatives--config javac

sudo update-alternatives--config javaws

Main references:

Http://wenku.baidu.com/view/f1b8592a192e45361066f5ad.html

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.