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

[经验分享] nginx+tomcat+LAMP-linux

[复制链接]

尚未签到

发表于 2018-11-16 08:52:51 | 显示全部楼层 |阅读模式
  nginx+tomcat+LAMP
  一、安装LAMP(apache+mysql+php)平台
  1、安装apache
  下载地址:http://sunsite.bilkent.edu.tr/pub/apache/httpd/httpd-2.2.9.tar.gz
  # tar zxf httpd-2.2.9.tar.gz -C /usr/src
  # cd /usr/src/httpd-2.2.9
  # ./configure    --prefix=/usr/local/apache  --enable-so --enable-mods-shared=all --enable-
  rewrite --enable-ssl --with-ssl=/usr/lib  --enable-auth-digest --enable-cgi --enable-suexec --
  with-suexec-caller=daemon --with-suexec- docroot=/usr/local/apache/htdocs
  # make && make install
  # cd /usr/local/apache/conf
  # ls
  # cp httpd.conf httpd.conf.bak
  # grep -v "#" httpd.conf.bak   | grep -v "^$" > httpd.conf
  # cd /usr/local/apache/htdocs
  # vi /usr/local/apache/conf/httpd.conf            (在最后编写)
  Listen 81
  NameVirtualHost  192.168.1.2
  
  DocumentRoot         /usr/local/apache/htdocs
  ServerName           www.benet.com
  ErrorLog             logs/www.benet.com.error.log
  CustomLog            logs/www.benet.com.access.log     common
  
  在浏览器中访问:http://www.benet.com:81
  2、安装mysql
  下载:百度中搜索:mysql for linux 即可
  # useradd -M -s /sbin/nologin  mysql
  # tar zxf mysql-5.0.56.tar.gz -C /usr/src
  # cd /usr/src/mysql-5.0.56
  # ./configure --prefix=/usr/local/mysql
  # make
  # make install
  # cp support-files/my-medium.cnf /etc/my.cnf
  # /usr/local/mysql/bin/mysql_install_db --user=mysql
  # chown -R root.mysql /usr/local/mysql/
  # chown -R mysql /usr/local/mysql/var
  # echo "/usr/local/mysql/lib/mysql"  >> /etc/ld.so.conf
  # ldconfig
  # /usr/local/mysql/bin/mysqld_safe  --user=mysql &
  # 回车(Enter键)
  # netstat -ntpl | grep 3306
  # cp support-files/mysql.server  /etc/init.d/mysqld
  # chmod +x /etc/init.d/mysqld
  # chkconfig --add mysqld
  # chkconfig --level 35 mysqld on
  # export PATH=$PATH:/usr/local/mysql/bin
  # echo "PATH=$PATH:/usr/local/mysql/bin"   >>  /etc/profile
  # mysqladmin -u root password "123456"
  # mysql -u root -p
  3、安装php
  下载地址:http://www.php.net/downloads/
  ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.30.tar.gz
  http://prdownloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
  http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib-1.2.3.tar.gz
  http://www.dnaphp.com/downloads/server/linux/18-gd-2-0-35-tar   (gd)
  ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
  http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
  http://sourceforge.net/projects/libpng/files/libpng15/1.5.6/libpng-1.5.6.tar.gz
  http://www.imagemagick.org/download/delegates/jpegsrc.v7.tar.gz
  http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
  http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
  所需库文件安装:
  # tar zxvf libxml2-2.6.30.tar.gz
  # cd libxml2-2.6.30
  # ./configure --prefix=/usr/local/libxml2
  # make && make install
  # tar zxvf libmcrypt-2.5.8.tar.gz
  # cd libmcrypt-2.5.8
  # ./configure --prefix=/usr/local/libmcrypt
  # make && make install
  # cd /usr/local/src/libmcrypt-2.5.8/libltdl
  # ./configure  --enable-ltdl-install
  # make && make install
  # tar zxvf zlib-1.2.3.tar.gz
  # cd zlib-1.2.3
  # ./configure --prefix=/usr/local/zlib
  # make && make install
  # tar zxvf libpng-1.2.31.tar.gz
  # cd libpng-1.2.31
  # ./configure --prefix=/usr/local/libpng
  # make && make install
  安装GD2库前所需的jpeg6库文件,需要自己手动地创建安装需要的目录,它们在安装时不能自动创建。
  # mkdir /usr/local/jpeg7                      //建立jpeg6软件安装目录
  # mkdir /usr/local/jpeg7/bin                  //建立存放命令的目录
  # mkdir /usr/local/jpeg7/lib                  //创建jpeg6库文件所在目录
  # mkdir /usr/local/jpeg7/include              //建立存放头文件目录
  # mkdir -p /usr/local/jpeg7/man/man1          //建立存放手册的目录
  # tar zxvf jpegsrc.v7.tar.gz
  # cd jpeg-v7
  # ./configure --prefix=/usr/local/jpeg7 --enable-shared --enable-static
  注:
  --enable-shared                                    //建立共享库使用的GNU的libtool
  --enable-static                                    //建立静态库使用的GNU的libtool
  # make && make install
  # tar zxvf freetype-2.3.5.tar.gz
  # cd  freetype-2.3.5
  # ./configure --prefix=/usr/local/freetype
  # make && make install
  # tar zxvf autoconf-2.61.tar.gz
  # cd autoconf-2.61
  # ./configure
  # make && make install
  # tar zxvf libiconv-1.13.tar.gz
  # cd libiconv-1.13/
  # ./configure --prefix=/usr/local/libiconv
  # make && make install
  # tar xzf gettext-0.17.tar.gz
  # cd gettext-0.17
  # ./configure
  # make && make install
  # tar zxvf gd-2.0.35.tar.gz
  # cd gd-2.0.35
  # ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib --with-jpeg=/usr/local/jpeg7 -
  -with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
  # make && make install
  # vi /usr/local/apache/conf/httpd.conf
  ....
  AddType  application/x-httpd-php  .php
  ....
  DirectoryIndex    index.php    index.html
  :wq
  # tar jxf php-5.2.6.tar.bz2 -C /usr/src
  # cd /usr/src/php-5.2.6
  # ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-
  apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-
  dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg7 --with-
  freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd2 --with-zlib-dir=/usr/local/zlib --with
  -mcrypt=/usr/local/libmcrypt --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --
  enable-mbstring=all --enable-sockets
  # make && make install
  # cp php.ini-dist  /usr/local/php/etc/php.ini
  # vi /usr/local/php/etc/php.ini
  extension_dir="/usr/lib/php/modules"        (原为extension_dir="./" )
  :wq
  # setenforce 0
  # chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
  # /usr/local/apache/bin/apachectl restart
  # setenforce 1
  测试:
  # vi /usr/local/apache/htdocs/test.php
  
  :wq
  # /usr/local/apache/bin/apachectl restart
  访问:http://www.benet.com/test.php
  二、安装tomcat
  1、安装JDK
  下载 jdk-7-linux-i586.rpm
  http://java.sun.com/javase/downloads/index.jsp
  # rpm –ivh jdk-7-linux-i586.rpm
  # vi ~/.bash_profile
  JAVA_HOME=/usr/java/jdk1.7.0
  CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
  PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

  export PATH>  使环境变量立刻生效
  # source ~/.bash_profile
  # source /etc/profile
  # java -version (jdk的版本为jdk1.4.2则表示jdk已成功安装)。
  2、安装Tomcat
  下载apache-tomcat-6.0.10.tar.gz
  http://jakarta.apache.org/tomcat
  # tar zxf apache-tomcat-6.0.10.tar.gz -C /usr/src
  # mv /usr/src/apache-tomcat-6.0.10   /usr/src/tomcat
  # /usr/src/tomcat/bin/startup.sh           (启动tomcat)
  或
  # /usr/src/tomcat/bin/catalina.sh start
  Using CATALINA_BASE: /usr/local/tomcat
  Using CATALINA_HOME: /usr/local/tomcat
  Using CATALINA_TEMDIR: /usr/local/tomcat/temp
  Using JAVA_HOME: /usr/java/jdk1.6.0_01
  # /usr/src/tomcat/bin/catalina.sh start/stop  (启动/关闭tomcat)
  到此tomcat已经安装完成,现在使用浏览器访问 http://localhost:8080,出现tomcat默认页面,
  系统重启后自动启动Tomcat:
  [root@tpwb ~]# vi /etc/rc.d/rc.local
  #!/bin/sh
  #
  # This script will be executed *after* all the other init scripts.
  # You can put your own initialization stuff in here if you don’t
  # want to do the full Sys V style init stuff.
  touch /var/lock/subsys/local
  export JDK_HOME=/usr/java/jdk1.7.0
  export JAVA_HOME=/usr/java/jdk1.7.0
  /usr/src/tomcat/bin/catalina.sh start
  设置虚拟主机:
  # vi /usr/src/tomcat/conf/server.xml
  

  
    prefix="www.benet.com_access_log." pattern="common" suffix=".txt"
  timestamp="true"/>
  
  # vi /usr/local/apache/htdocs/hello.jsp
  
  浏览器中访问:http://www.benet.com/hello.jsp
  三、安装nginx
  Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。
  http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.7.51.tar.gz
  http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.8.tar.gz
  # tar zxvf pcre-7.9.tar.gz
  # cd pcre-7.9
  # ./configure
  # make && make install
  # tar zxf nginx-0.7.51.tar.gz
  # cd nginx-0.7.51
  # ./configure
  # make && make install
  nginx安装成功后的安装目录为/usr/local/nginx
  配置虚拟主机
  # vi usr/local/nginx/conf/nginx.conf
  在http中加上server {
  listen       80;
  charset utf8;
  server_name  www.benet.com;
  root  /usr/local/apache/htdocs;
  index  index.html index.php index.jsp;
  location ~ \.jsp$
  {
  proxy_pass   http://127.0.0.1:8080;
  }
  location ~ \.php$
  {
  proxy_pass   http://127.0.0.1:81;
  }
  }
  启动nginx:
  # /usr/local/nginx/sbin/nginx
  在浏览器中访问:http://www.benet.com   和  http://www.benet.com/hello.jsp   和
  http://www.benet.com/test.php


运维网声明 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-635597-1-1.html 上篇帖子: php-nginx...tips 下篇帖子: nginx的相关配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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