设为首页 收藏本站
查看: 682|回复: 0

[经验分享] centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)

[复制链接]

尚未签到

发表于 2018-12-7 09:05:56 | 显示全部楼层 |阅读模式
  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环境搭建
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-644199-1-1.html 上篇帖子: Eclipse中将web项目自动发布到Tomcat webapps下 下篇帖子: Tomcat启动web项目报Bad version number in .class file (unable to load class ...)错
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表