centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)相关的知识,希望对你有一定的参考价值。
centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)
第一部分LNMP环境搭建
一、编译安装nginx1.10.3
1、准备
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[[email protected] ~]# 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
[[email protected] ~]# uname -r
3.10.0-514.el7.x86_64
[[email protected] ~]# uname -mx86_64
[[email protected] ~]# groupadd nginx
[[email protected] ~]# useradd nginx -s /sbin/nologin -g nginx -M
[[email protected] ~]# mkdir -p /home/qiu/tools
[[email protected] ~]# mkdir /application
[[email protected] ~]# yum -y install pcre pcre-devel openssl openssl-devel
[[email protected] ~]# rpm -qa install pcre pcre-devel openssl openssl-devel
2、下载、解压nginx
[[email protected] ~]# cd /home/qiu/tools[[email protected] tools]# wget [[email protected] tools]# tar xf nginx-1.10.3.tar.gz[[email protected] tools]# cd nginx-1.10.3/
3、安装nginx
[[email protected] nginx-1.10.3]# ./configure --help
[[email protected] nginx-1.10.3]# ./configure --prefix=/application/nginx-1.10.3 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
[[email protected] nginx-1.10.3]# echo $?
0
[[email protected] nginx-1.10.3]# make
[[email protected] nginx-1.10.3]# echo $?
0
[[email protected] nginx-1.10.3]# make install
[[email protected] nginx-1.10.3]# echo $?
0
[[email protected] nginx-1.10.3]# history
[[email protected] nginx-1.10.3]# ln -s /application/nginx-1.10.3/ /application/nginx
4、开启nginx
[[email protected] nginx-1.10.3]# /application/nginx/sbin/nginx -t
[[email protected] nginx-1.10.3]# /application/nginx/sbin/nginx
[[email protected] nginx-1.10.3]# netstat -luntp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8048/nginx: master [[email protected] 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)
[[email protected] nginx-1.10.3]# systemctl stop firewalld.service
[[email protected] nginx-1.10.3]# setenforce o
5、测试
二、安装MySQL(二进制方法)
1、准备
[[email protected] tools]# groupadd mysql
[[email protected] tools]# useradd mysql -s /sbin/nologin -g mysql -M
[[email protected] tools]# id mysqluid=1002(mysql) gid=1002(mysql) groups=1002(mysql)
2、下载、验证、解压
[[email protected] ~]# cd /home/qiu/tools/
[[email protected] tools]# wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
[[email protected] tools]# tar xf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
[[email protected] 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
[[email protected] tools]# mv mysql-5.5.57-linux-glibc2.12-x86_64 /application/mysql-5.5.57-linux-glibc2.12-x86_64
[[email protected] tools]# cd /application/
[[email protected] application]# lsmysql-5.5.57-linux-glibc2.12-x86_64 nginx nginx-1.10.3
[[email protected] application]# ln -s mysql-5.5.57-linux-glibc2.12-x86_64 mysql
3、安装
[[email protected] tools]# cd /application/mysql
[[email protected] mysql]# chown -R mysql.mysql /application/mysql
[[email protected] tools]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/datacp mysql.server /etc/init.d/mysqld
[[email protected] tools]#chown -R mysql.mysql /application/mysql/
[[email protected] tools]# echo "export PATH=/application/mysql/bin:$PATH" >>/etc/profile
[[email protected] tools]# source /etc/profile
[[email protected] tools]# sed -i ‘s#/usr/local/mysql#/applicaton/mysql#g‘ /etc/init.d/mysqld /application/mysql/bin/mysqld_safe
[[email protected] tools]# /etc/init.d/mysqld start
4、测试
[[email protected] 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
[[email protected] 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)
[[email protected] support-files]# netstat -luntp|grep mysqltcp
0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11600/mysqld
[[email protected] 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、准备
[[email protected] support-files]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [[email protected] 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
[[email protected] support-files]# uname -r
3.10.0-514.el7.x86_64
[[email protected] support-files]# uname -m
x86_64
[[email protected] support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[[email protected] support-files]# yum -y install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[[email protected] support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[[email protected] support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
[[email protected] support-files]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
[[email protected] support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
安装biconv库[[email protected] support-files]# cd /home/qiu/tools/
[[email protected] tools]# wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[[email protected] tools]# tar zvxf libiconv-1.15.tar.gz
[[email protected] tools]# cd libiconv-1.15/
[[email protected] tlibiconv-1.15]# ./configure --prefix=/usr/local/libiconv
[[email protected] tlibiconv-1.15]# make[[email protected] libiconv-1.15]# make install[[email protected] libiconv-1.15]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[[email protected] libiconv-1.15]# yum -y install libmcrypt-devel
[[email protected] libiconv-1.15]# yum -y install mhash[[email protected] libiconv-1.15]# yum -y install mcrypt
2、下载
[[email protected] /]# cd /home/qiu/tools/
[[email protected] tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
[[email protected] tools]# tar zxf php-5.5.32.tar.gz [[email protected] 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
[[email protected] php]# cd /home/qiu/tools/php-5.5.32/
[[email protected] php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[[email protected] php-5.5.32]# cd /application/php/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
4、测试
[[email protected] etc]# /application/php/sbin/php-fpm
[[email protected] etc]# ps -rf|grep php-fpm
[[email protected] 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
[[email protected] 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)[[email protected] 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环境搭建
本文出自 “doublelinux” 博客,谢绝转载!
以上是关于centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)的主要内容,如果未能解决你的问题,请参考以下文章