CentOS7 installation of Nginx + MongoDB + Wildfly

Source: Internet
Author: User
Tags jboss wildfly

I. Preparation

The following are the system and software versions used for this installation:

    • CentOS 7.0

    • Nginx 1.9.3

    • MongoDB 3.0.5

    • Wildfly 9.0.1

    • JDK 8u51

Installation Nginx also needs to Pcre and Zlib, their version is:

    • Pcre 8.37

    • Zlib 1.2.7

Two. Install the operating system1. Installation Interface language

CentOS 7 Installation Guide interface is clear, the Installation interface language Select Simplified Chinese can.

2. Summary of installation Information

There is a software selection in the installation Information summary interface, which defines a collection of packages for common scenarios where we select the infrastructure server.

Infrastructure Server is not a visual interface, if you need a visual interface, you can choose a server with a GUI.

In the installation target location, you can customize the partitioning of the disk as needed.

CentOS 7 Default partition disk recommended boot size is 500M, if custom partition disk, it is recommended to set boot to 500M.

The System network card is disabled by default and can be enabled in Network & HOST NAME.

Once setup is complete, you can continue with the installation.

3. Installation process

During the installation process, you need to set the root user's password. If you selected the infrastructure server in the previous step, the entire installation process will end quickly, if you choose a server with a GUI, then the installation process will be slightly slower, and the installation will require a normal user to set up for normal operation of the system.

4. Install the compiler

When you choose to install the Software collection, if no additional packages are selected, the system is not with the GCC compiler by default, we need to install them, the installation process is simple

# yum Install gcc gcc-c++

Three. Installing Nginx

Install Nginx need to pcre and zlib, here we need to download three software source package, the source code compiled by the way to install and configure.

After extracting Nginx, Pcre and zlib, go to Nginx directory to execute:

#./configure--prefix=/usr/local/nginx-1.9.3--with-zlib=. /zlib-1.2.7--with-pcre=. /pcre-8.37

--PREFIX Specifies the installation directory for Nginx

--with-zlib is pointing to Zlib's source package.

--with-pcre is pointing to Pcre's source package.

Once the configuration is complete, you can install the

# Make && make install

After installation, you need to set up the appropriate user groups and users, and adjust the Nginx directory permissions and Configuration

Modify Nginx Configuration

# vi/usr/local/nginx-1.9.3/conf/nginx.conf

Will

#user nobody; #pid logs/nginx.pid; #access_log Logs/access.log main;

Remove the comment and change it to

User Nginx;pid/usr/local/nginx-1.9.3/nginx.pid;access_log/www/log/nginx/access.log main;

Adding user groups and users

# Groupadd nginx# useradd-g Nginx

To adjust Nginx directory permissions

# chown Nginx:nginx/usr/local/nginx-1.9.3-r

Then create the Nginx log directory and set the appropriate directory permissions.

# mkdir-p/www/log/nginx# chown nginx:nginx/www/log/nginx-r

Four. Configure Nginx

There are two main things to do in configuring Nginx: 1. Configure the Nginx boot from the boot, 2. Configure the firewall to allow extranet access to port 80.

1. Configure Nginx Boot

Create a new Nginx service script under/lib/systemd/system

# Touch/lib/systemd/system/nginx.service

Then type the following:

[Unit] Description=the nginx HTTP and reverse proxy serverafter=network.target Remote-fs.target Nss-lookup.target[service] type=forkingpidfile=/usr/local/nginx-1.9.3/nginx.pidexecstartpre=/usr/local/nginx-1.9.3/sbin/nginx-texecstart= /usr/local/nginx-1.9.3/sbin/nginxexecreload=/bin/kill-s HUP $MAINPIDKillMode =processkillsignal= Sigquittimeoutstopsec=5privatetmp=true[install]wantedby=multi-user.target

After saving, execute

# Systemctl Enable Nginx.service

Enable Nginx to boot, to cancel the boot can be executed

# systemctl Disable Nginx.service

Start Nginx to perform

# Systemctl Start Nginx.service

Heavy-duty Nginx configuration can be performed

# Systemctl Reload Nginx.service

View Nginx run status can be performed

# SYSTEMCTL Status Nginx.service

2. Configure the Firewall

Once the Nginx installation is complete, you will also need to configure the rules on the firewall to allow 80 port requests to pass. The method is simple and performs

# firewall-cmd--permanent--zone=public--add-service=http

Then restart the firewall to take effect

# systemctl Restart Firewalld.service

3. Testing

Use the browser to access the server address, see Nginx Welcome Interface Description of the successful configuration.

Five. Install and configure MongoDB

Extract MongoDB to/usr/local/mongodb-3.0.5

Add a configuration file for MongoDB

# touch/usr/local/mongodb-3.0.5/mongodb.conf

Type the following:

SystemLog:destination:file path:/www/log/mongodb/mongodb.log logAppend:trueprocessManagement:fork:true pid FilePath:/usr/local/mongodb-3.0.5/mongodb.pidstorage:dbpath:/data/mongodb directoryperdb:true

To add user groups and users:

# groupadd mongodb# useradd-g MongoDB MongoDB

Adjust the directory permissions for MongoDB

# chown Mongodb:mongodb/usr/local/mongodb-3.0.5-r

Then create the MongoDB data directory and log directory, and set the appropriate directory permissions.

# mkdir-p/www/log/mongodb# chown mongodb:mongodb/www/log/mongodb-r# mkdir-p/data/mongodb# chown Mongodb:mongodb/dat A/mongodb-r

Create a new MongoDB service script under/lib/systemd/system

# Touch/lib/systemd/system/mongodb.service

Then type the following:

[Unit] Description=mongodbafter=network.target Remote-fs.target nss-lookup.target[service]type=forkingpidfile=/usr/ Local/mongodb-3.0.5/mongodb.pidexecstartpre=/bin/rm-rf/data/mongodb/mongod.lockexecstart=/bin/su-mongodb-c "/ Usr/local/mongodb-3.0.5/bin/mongod--config/usr/local/mongodb-3.0.5/mongodb.conf "Execstop=/bin/kill-2 $ Mainpidkillmode=processkillsignal=sigquittimeoutstopsec=5privatetmp=true[install]wantedby=multi-user.target

After saving, execute the following command to add the boot boot

# Systemctl Enable Mongodb.service

Execute the following command to start MongoDB

# Systemctl Start Mongodb.service

Six. Installing the configuration JDK

unzip the JDK to/usr/local/jdk1.8.0_51

In/etc/profile last added

Export Java_home=/usr/local/jdk1.8.0_51export path= $JAVA _home/bin: $PATH export classpath=.: $JAVA _home/lib/dt.jar:$ Java_home/lib/tools.jar

Save after execution

# Source/etc/profile

is the environment variable in effect, by

# java-version

Check if configuration is successful

Seven. Installation Configuration Wildfly

unzip the Wildfly to/usr/local/wildfly-9.0.1.final

1. Modify the Boot configuration file
# vi/usr/local/wildfly-9.0.1.final/bin/init.d/wildfly.conf

The following configuration

# java_home= "/usr/lib/jvm/default-java" # jboss_home= "/opt/wildfly" # Jboss_user=wildfly

Remove the comment and change it to

Java_home= "/usr/local/jdk1.8.0_51" jboss_home= "/usr/local/wildfly-9.0.1.final" jboss_user=www

2. Modify the startup script
# vi/usr/local/wildfly-9.0.1.final/bin/init.d/wildfly-init-redhat.sh

Found it

jboss_conf= "/etc/default/wildfly.conf"

Revision changed to

jboss_conf= "/usr/local/wildfly-9.0.1.final/bin/init.d/wildfly.conf"

Found it

Jboss_home=/opt/wildfly

Revision changed to

Jboss_home=/usr/local/wildfly-9.0.1.final

Found it

Jboss_pidfile=/var/run/wildfly/wildfly.pid

Revision changed to

Jboss_pidfile=/usr/local/wildfly-9.0.1.final/wildfly.pid

Found it

Jboss_console_log=/var/log/wildfly/console.log

Revision changed to

Jboss_console_log=/www/log/jboss/console.log

Modify the Wildfly log directory

Edit the following file

# Vi/usr/local/wildfly-9.0.1.final/standalone/configuration/standalone.xml

Found it

<file relative-to= "Jboss.server.log.dir" path= "Server.log"/>

Revision changed to

<file path= "/www/log/jboss/server.log"/>

Adding user groups and users
# groupadd www# useradd-g www www

Adjust directory permissions for Wildfly

# chown Www:www/usr/local/wildfly-9.0.1.final-r

Then create the log directory for the Wildfly and set the appropriate directory permissions

# mkdir-p/www/log/jboss# chown www:www/www/log/jboss-r

To add a startup script

Create a new Wildfly service script under/lib/systemd/system

# Touch/lib/systemd/system/jboss.service

Then type the following:

[Unit] Description=wildflyafter=network.target Remote-fs.target nss-lookup.target[service]type=forkingexecstart=/usr/ Local/wildfly-9.0.1.final/bin/init.d/wildfly-init-redhat.sh startexecstop=/usr/local/wildfly-9.0.1.final/bin/ Init.d/wildfly-init-redhat.sh Stop[install]wantedby=multi-user.target

After saving, execute the following command to add the boot boot

# Systemctl Enable Jboss.service

Execute the following command to start Wildfly

# Systemctl Start Jboss.service

Eight. Tuning

After the above steps, the required software is installed, and then some settings need to be made to optimize the system.

1. MongoDB Tuning

MongoDB Run recommended disable large memory page (http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/)

New script

# touch/etc/init.d/disable-transparent-hugepages

Type the following:

#!/bin/sh### begin init info# provides:           disable-transparent-hugepages# Required-Start:     $local _fs#  required-stop:# x-start-before:    mongod mongodb-mms-automation-agent#  default-start:     2 3 4 5# default-stop:       0 1 6# Short-Description: Disable Linux transparent huge  pages# description:       disable linux transparent  huge pages, to improve#                     database performance.### end init infocase  $1 in  start)     if [ -d /sys/kernel/mm/transparent_ Hugepage ]; then&nbSp;     thp_path=/sys/kernel/mm/transparent_hugepage    elif  [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then       thp_path=/sys/kernel/mm/redhat_transparent_hugepage    else       return 0    fi    echo  ' Never '  >  ${thp_path}/enabled    echo  ' Never '  > ${thp_path}/defrag     unset thp_path    ;; Esac

After saving, modify the executable permissions of the file

# chmod +x/etc/init.d/disable-transparent-hugepages

Create a new startup script under/lib/systemd/system

# Touch/lib/systemd/system/dthp.service

Then type the following:

[Unit] Description=disable Transparent Huge Pages (THP) [service]execstart=/etc/init.d/disable-transparent-hugepages Starttimeoutstopsec=5privatetmp=true[install]wantedby=multi-user.target

After saving, execute the following command to add the boot boot

# Systemctl Enable Dthp.service

Execute the following command to start the script

# Systemctl Start Dthp.service

can take effect after restarting MongoDB

2. Ulimit Tuning

Edit/etc/security/limits.conf

# vi/etc/security/limits.conf

Add the following configuration

* Soft nofile 65536* hard Nofile 65536

After saving, exit the current user, log back in and execute

# Ulimit-n

See if it takes effect

CentOS7 installation of Nginx + MongoDB + Wildfly

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.