jdgue 发表于 2018-12-7 09:05:56

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

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

  第一部分LNMP环境搭建
  一、编译安装nginx1.10.3
  1、准备
  # cat /etc/redhat-release
  CentOS Linux release 7.3.1611 (Core)
  # 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
  # uname -r
  3.10.0-514.el7.x86_64
  # uname -mx86_64
  # groupadd nginx
  # useradd nginx -s /sbin/nologin -g nginx -M
  # mkdir -p /home/qiu/tools
  # mkdir /application
  # yum -y install pcre pcre-devel openssl openssl-devel
  # rpm -qainstall pcre pcre-devel openssl openssl-devel

  2、下载、解压nginx
  # cd /home/qiu/tools# wget# tar xf nginx-1.10.3.tar.gz# cd nginx-1.10.3/

  3、安装nginx
  # ./configure --help
  #./configure --prefix=/application/nginx-1.10.3 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
  #echo $?
  0
  # make
  # echo $?
  0
  # make install
  # echo $?
  0
  #history
  # ln -s /application/nginx-1.10.3/ /application/nginx

  4、开启nginx
  # /application/nginx/sbin/nginx -t
  # /application/nginx/sbin/nginx
  # netstat -luntp|grep 80
  tcp      0      0 0.0.0.0:80            0.0.0.0:*               LISTEN      8048/nginx: master# lsof -i:80
  COMMANDPIDUSER   FD   TYPE DEVICE SIZE/OFF NODE NAMEnginx   8048root    6uIPv456025      0t0TCP *:http (LISTEN)nginx   8049 nginx    6uIPv456025      0t0TCP *:http (LISTEN)
  # systemctl stop firewalld.service
  # setenforce o

  5、测试
  

  

  二、安装MySQL(二进制方法)
  1、准备
  # groupadd mysql
  # useradd mysql -s /sbin/nologin -g mysql -M
  # id mysqluid=1002(mysql) gid=1002(mysql) groups=1002(mysql)

  2、下载、验证、解压
  # cd /home/qiu/tools/
  # wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
  # tar xf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
  # lsmysql-5.5.57-linux-glibc2.12-x86_64mysql-5.5.57-linux-glibc2.12-x86_64.tar.gznginx-1.10.3nginx-1.10.3.tar.gz
  # mv mysql-5.5.57-linux-glibc2.12-x86_64 /application/mysql-5.5.57-linux-glibc2.12-x86_64
  # cd /application/
  # lsmysql-5.5.57-linux-glibc2.12-x86_64nginxnginx-1.10.3
  # ln -s mysql-5.5.57-linux-glibc2.12-x86_64 mysql

  3、安装
  # cd /application/mysql
  # chown -R mysql.mysql /application/mysql
# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/datacp mysql.server /etc/init.d/mysqld
#chown -R mysql.mysql /application/mysql/
# echo "export PATH=/application/mysql/bin:$PATH" >>/etc/profile
#source /etc/profile
# sed -i 's#/usr/local/mysql#/applicaton/mysql#g' /etc/init.d/mysqld /application/mysql/bin/mysqld_safe
# /etc/init.d/mysqld start

  4、测试

  # ps -ef|grep 3306
  mysql   11600113640 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   26590 04:24 pts/0    00:00:00 grep --color=auto 3306
  # lsof -i:80
  COMMANDPIDUSER   FD   TYPE DEVICE SIZE/OFF NODE NAMEnginx   8048root    6uIPv456025      0t0TCP *:http (LISTEN)nginx   8049 nginx    6uIPv456025      0t0TCP *:http (LISTEN)
  # netstat -luntp|grep mysqltcp
  0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      11600/mysqld
  # 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、准备
  # cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) # 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
  # uname -r
  3.10.0-514.el7.x86_64
  # uname -m
  x86_64
  # rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
  # yum -y installfreetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
  # rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
  # rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
  # yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
  # rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
安装biconv库# cd /home/qiu/tools/
  # wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
  # tar zvxf libiconv-1.15.tar.gz
  # cd libiconv-1.15/
  # ./configure --prefix=/usr/local/libiconv
  # make# make install# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  # yum -y install libmcrypt-devel
  # yum -y install mhash# yum -y install mcrypt

  

  

  2、下载
  # cd /home/qiu/tools/
  # wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
  # tar zxf php-5.5.32.tar.gz # 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
  # cd /home/qiu/tools/php-5.5.32/
  # cp php.ini-production /application/php/lib/php.ini
  # cd /application/php/etc/
  # cp php-fpm.conf.default php-fpm.conf

  

  

  4、测试
  # /application/php/sbin/php-fpm
  # ps -rf|grep php-fpm
  # ps -ef|grep php-fpm
  root      44740      10 08:46 ?      00:00:00 php-fpm: master process (/application/php-5.5.32/etc/php-fpm.conf)nginx   44741447400 08:46 ?      00:00:00 php-fpm: pool wwwnginx   44742447400 08:46 ?      00:00:00 php-fpm: pool wwwroot      44747   26590 08:46 pts/0    00:00:00 grep --color=auto php-fpm
  # lsof -i:9000
  COMMAND   PIDUSER   FD   TYPE DEVICE SIZE/OFF NODE NAMEphp-fpm 44740root    7uIPv4 251732      0t0TCP localhost:cslistener (LISTEN)php-fpm 44741 nginx    0uIPv4 251732      0t0TCP localhost:cslistener (LISTEN)php-fpm 44742 nginx    0uIPv4 251732      0t0TCP localhost:cslistener (LISTEN)# 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环境搭建
  




页: [1]
查看完整版本: centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)