centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)

前端之家收集整理的这篇文章主要介绍了centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos搭建LNMP+LAMP环境+(jdk+tomcat+MysqL

第一部分LNMP环境搭建

一、编译安装Nginx1.10.3

1、准备

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

[root@localhost ~]# uname -a

Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# uname -r

3.10.0-514.el7.x86_64

[root@localhost ~]# uname -mx86_64

[root@localhost ~]# groupadd Nginx

[root@localhost ~]# useradd Nginx -s /sbin/nologin -g Nginx -M

[root@localhost ~]# mkdir -p /home/qiu/tools

[root@localhost ~]# mkdir /application

[root@localhost ~]# yum -y install pcre pcre-devel openssl openssl-devel

[root@localhost ~]# rpm -qa install pcre pcre-devel openssl openssl-devel

2、下载、解压Nginx

[root@localhost ~]# cd /home/qiu/tools[root@localhost tools]# wget [root@localhost tools]# tar xf Nginx-1.10.3.tar.gz[root@localhost tools]# cd Nginx-1.10.3/

3、安装Nginx

[root@localhost Nginx-1.10.3]# ./configure --help

[root@localhost Nginx-1.10.3]# ./configure --prefix=/application/Nginx-1.10.3 --user=Nginx --group=Nginx --with-http_stub_status_module --with-http_ssl_module

[root@localhost Nginx-1.10.3]# echo $?

0

[root@localhost Nginx-1.10.3]# make

[root@localhost Nginx-1.10.3]# echo $?

0

[root@localhost Nginx-1.10.3]# make install

[root@localhost Nginx-1.10.3]# echo $?

0

[root@localhost Nginx-1.10.3]# history

[root@localhost Nginx-1.10.3]# ln -s /application/Nginx-1.10.3/ /application/Nginx

4、开启Nginx

[root@localhost Nginx-1.10.3]# /application/Nginx/sbin/Nginx -t

[root@localhost Nginx-1.10.3]# /application/Nginx/sbin/Nginx

[root@localhost Nginx-1.10.3]# netstat -luntp|grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8048/Nginx: master [root@localhost Nginx-1.10.3]# lsof -i:80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMENginx 8048 root 6u IPv4 56025 0t0 TCP *:http (LISTEN)Nginx 8049 Nginx 6u IPv4 56025 0t0 TCP *:http (LISTEN)

[root@localhost Nginx-1.10.3]# systemctl stop firewalld.service

[root@localhost Nginx-1.10.3]# setenforce o

5、测试



二、安装MysqL(二进制方法

1、准备

[root@localhost tools]# groupadd MysqL

[root@localhost tools]# useradd MysqL -s /sbin/nologin -g MysqL -M

[root@localhost tools]# id MysqLuid=1002(MysqL) gid=1002(MysqL) groups=1002(MysqL)

2、下载、验证、解压

[root@localhost ~]# cd /home/qiu/tools/

[root@localhost tools]# wget https://dev.MysqL.com/get/Downloads/MysqL-5.5/MysqL-5.5.57-linux-glibc2.12-x86_64.tar.gz

[root@localhost tools]# tar xf MysqL-5.5.57-linux-glibc2.12-x86_64.tar.gz

[root@localhost tools]# lsMysqL-5.5.57-linux-glibc2.12-x86_64 MysqL-5.5.57-linux-glibc2.12-x86_64.tar.gz Nginx-1.10.3 Nginx-1.10.3.tar.gz

[root@localhost tools]# mv MysqL-5.5.57-linux-glibc2.12-x86_64 /application/MysqL-5.5.57-linux-glibc2.12-x86_64

[root@localhost tools]# cd /application/

[root@localhost application]# lsMysqL-5.5.57-linux-glibc2.12-x86_64 Nginx Nginx-1.10.3

[root@localhost application]# ln -s MysqL-5.5.57-linux-glibc2.12-x86_64 MysqL

3、安装

[root@localhost tools]# cd /application/MysqL

[root@localhost MysqL]# chown -R MysqL.MysqL /application/MysqL
[root@localhost tools]# ./MysqL_install_db --user=MysqL --basedir=/application/MysqL --datadir=/application/MysqL/datacp MysqL.server /etc/init.d/MysqLd
[root@localhost tools]#chown -R MysqL.MysqL /application/MysqL/
[root@localhost tools]# echo "export PATH=/application/MysqL/bin:$PATH" >>/etc/profile
[root@localhost tools]# source /etc/profile
[root@localhost tools]# sed -i 's#/usr/local/MysqL#/applicaton/MysqL#g' /etc/init.d/MysqLd /application/MysqL/bin/MysqLd_safe
[root@localhost tools]# /etc/init.d/MysqLd start

4、测试

[root@localhost support-files]# ps -ef|grep 3306

MysqL 11600 11364 0 02:58 pts/0 00:00:02 /application/MysqL/bin/MysqLd --basedir=/application/MysqL --datadir=/application/MysqL/data --plugin-dir=/application/MysqL/lib/plugin --user=MysqL --log-error=localhost.localdomain.err --pid-file=/application/MysqL/data/localhost.localdomain.pid --socket=/tmp/MysqL.sock --port=3306root 15899 2659 0 04:24 pts/0 00:00:00 grep --color=auto 3306

[root@localhost support-files]# lsof -i:80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMENginx 8048 root 6u IPv4 56025 0t0 TCP *:http (LISTEN)Nginx 8049 Nginx 6u IPv4 56025 0t0 TCP *:http (LISTEN)

[root@localhost support-files]# netstat -luntp|grep MysqLtcp

0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11600/MysqLd

[root@localhost support-files]# MysqLWelcome to the MysqL monitor. Commands end with ; or \g.Your MysqL connection id is 4Server version: 5.5.57 MysqL Community Server (GPL)Copyright (c) 2000,2017,Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MysqL>

三、fastcgi方式安装PHP

1、准备

[root@localhost support-files]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@localhost support-files]# uname -aLinux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost support-files]# uname -r

3.10.0-514.el7.x86_64

[root@localhost support-files]# uname -m

x86_64

[root@localhost support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel

[root@localhost support-files]# yum -y install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel

[root@localhost support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel

[root@localhost support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

[root@localhost support-files]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

[root@localhost support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
安装biconv库[root@localhost support-files]# cd /home/qiu/tools/

[root@localhost tools]# wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz

[root@localhost tools]# tar zvxf libiconv-1.15.tar.gz

[root@localhost tools]# cd libiconv-1.15/

[root@localhost tlibiconv-1.15]# ./configure --prefix=/usr/local/libiconv

[root@localhost tlibiconv-1.15]# make[root@localhost libiconv-1.15]# make install[root@localhost libiconv-1.15]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@localhost libiconv-1.15]# yum -y install libmcrypt-devel

[root@localhost libiconv-1.15]# yum -y install mhash[root@localhost libiconv-1.15]# yum -y install mcrypt



2、下载

[root@localhost /]# cd /home/qiu/tools/

[root@localhost tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz

[root@localhost tools]# tar zxf PHP-5.5.32.tar.gz [root@localhost tools]# cd PHP-5.5.32



3、安装

./configure \

--prefix=/application/PHP-5.5.32 \

--with-MysqL=/application/MysqL \

--with-pdo-MysqL=MysqLnd \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-safe-mode \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--enable-ftp \

--with-fpm-user=Nginx \

--with-fpm-group=Nginx \

--enable-opcache=yes


make

make install

[root@localhost PHP]# cd /home/qiu/tools/PHP-5.5.32/

[root@localhost PHP-5.5.32]# cp PHP.ini-production /application/PHP/lib/PHP.ini

[root@localhost PHP-5.5.32]# cd /application/PHP/etc/

[root@localhost etc]# cp PHP-fpm.conf.default PHP-fpm.conf



4、测试

[root@localhost etc]# /application/PHP/sbin/PHP-fpm

[root@localhost etc]# ps -rf|grep PHP-fpm

[root@localhost etc]# ps -ef|grep PHP-fpm

root 44740 1 0 08:46 ? 00:00:00 PHP-fpm: master process (/application/PHP-5.5.32/etc/PHP-fpm.conf)Nginx 44741 44740 0 08:46 ? 00:00:00 PHP-fpm: pool wwwNginx 44742 44740 0 08:46 ? 00:00:00 PHP-fpm: pool wwwroot 44747 2659 0 08:46 pts/0 00:00:00 grep --color=auto PHP-fpm

[root@localhost etc]# lsof -i:9000

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEPHP-fpm 44740 root 7u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)PHP-fpm 44741 Nginx 0u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)PHP-fpm 44742 Nginx 0u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)[root@localhost etc]# netstat -luntp|grep PHP-fpmtcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 44740/PHP-fpm: mast



第二部分LAMP环境搭建






第三部分tomcat+jdk+MysqL环境搭建

猜你在找的CentOS相关文章