网站建设资讯

NEWS

网站建设资讯

搭建lnmp+tomcat+jdk环境与安装zrblog

下载nginx、php、tomcat
jdk需要在网页上下载到windows,再上传到机器上

创新互联建站坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的晋安网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

[root@Centos-1 src]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz [root@Centos-1 src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz [root@Centos-1 src]# wget http://nginx.org/download/nginx-1.12.1.tar.gz

解压nginx、mysql、php、tomcat 、 jdk

[root@Centos-1 src]# tar -zxvf php-5.6.30.tar.gz [root@Centos-1 src]# tar -zxvf nginx-1.12.1.tar.gz [root@Centos-1 src]# tar -zxvf apache-tomcat-8.5.20.tar.gz [root@Centos-1 src]# tar -zxvf jdk-8u144-linux-x64.tar.gz

安装编译php依赖库libmcrypt

#下载和解压libmcrypt [root@Centos-1 src]# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz [root@Centos-1 src]# tar -zxvf libmcrypt-2.5.7.tar.gz 第2步:进入libmcrypt目录,编译&安装 [root@Centos-1 src]# cd libmcrypt-2.5.7 [root@Centos-1 libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt [root@Centos-1 libmcrypt-2.5.7]# make && make install

php安装编译

#初始化 [root@Centos-1 php-5.6.30]#./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm -with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-libmcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-tty --enable-ftp --enable-mbstring --enable-exif--with-pear --with-curl --with-openssl #安装 [root@Centos-1 php-5.6.30]# make && make install

拷贝配置文件

#拷贝到/etc/下,并重命名 [root@Centos-1 php-5.6.30]# cp php.ini-production /usr/local/php-fpm/etc/php.ini

拷贝启动脚本

# /etc/init.d下,重命名为php-fpm,并给它设置权限为755 [root@Centos-1 php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp:是否覆盖"/etc/init.d/php-fpm"? y [root@Centos-1 php-5.6.30]# chmod 755 /etc/init.d/php-fpm

进入/usr/local/php-fpm/etc/目录,开启自定义pool

[root@Centos-1 php-5.6.30]# cd /usr/local/php-fpm/etc/ [root@Centos-1 etc]# vim php-fpm.conf [global] pid = /usr/local/php-fpm/var/run/php-fpm.pid error_log = /usr/local/php-fpm/var/log/php-fpm.log include = etc/php-fpm.d/*.conf //可以自定义pool

创建自定义pool目录

[root@Centos-1 etc]# pwd /usr/local/php-fpm/etc [root@Centos-1 etc]# mkdir php-fpm.d [root@Centos-1 etc]#cd php-fpm.d/ [root@Centos-1 php-fpm.d]# vim bbs.conf [bbs] listen = /tmp/zrblog.sock listen.mode = 666 user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024

将php-fpm加入到服务列表

[root@Centos-1 php-fpm.d]# chkconfig --add php-fpm #配置开机启动php-fpm [root@Centos-1 php-fpm.d]# chkconfig php-fpm on

开启服务器

[root@Centos-1 php-fpm.d]#service php-fpm start #查看进程,服务是否开启 [root@Centos-1 php-fpm.d]# ps aux |grep php-fpm root 22757 0.0 0.2 213452 4984 ? Ss 14:01 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 22758 0.0 0.2 213452 4460 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22759 0.0 0.2 213452 4460 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22760 0.0 0.2 213452 4460 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22761 0.0 0.2 213452 4460 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22762 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22763 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22764 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22765 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22766 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22767 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22768 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22769 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22770 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22771 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22772 0.0 0.2 213452 4464 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22773 0.0 0.2 213452 4468 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22774 0.0 0.2 213452 4468 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22775 0.0 0.2 213452 4468 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22776 0.0 0.2 213452 4468 ? S 14:01 0:00 php-fpm: pool bbs php-fpm 22777 0.0 0.2 213452 4468 ? S 14:01 0:00 php-fpm: pool bbs root 27101 0.0 0.0 112676 984 pts/0 R+ 17:37 0:00 grep --color=auto php-fpm

进入nginx目录,编译和安装

[root@Centos-1 src]# cd nginx-1.12.1 #编译 [root@Centos-1 nginx-1.12.1]# ./configure --prefix=/usr/local/nginx #安装 [root@Centos-1 nginx-1.12.1]# make && make install

定制启动脚本

[root@Centos-1 nginx-1.12.1]# vim /etc/init.d/nginx #!/bin/bash # chkconfig: - 30 21 # description: http service. # Source Function Library . /etc/init.d/functions # Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" RETVAL=0 prog="Nginx" start() { echo -n $"Starting $prog: " mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? echo return $RETVAL } reload() { echo -n $"Reloading $prog: " killproc -p $NGINX_PID $NGINX_SBIN -HUP RETVAL=$? echo return $RETVAL } restart() { stop start } configtest() { $NGINX_SBIN -c $NGINX_CONF -t return 0 } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|reload|restart|configtest}" RETVAL=1 esac exit $RETVAL #更改配置启动脚本权限 [root@Centos-1 nginx-1.12.1]# chmod 755 /etc/init.d/nginx

自定义 nginx.conf 配置文件

进入配置文件目录 [root@Centos-1 nginx-1.12.1]# cd /usr/local/nginx/conf/ 为了安全把,原有的nginx.conf改名 [root@Centos-1 conf]# mv nginx.conf nginx.conf.1 [root@Centos-1 conf]# vimnginx.conf user nobody nobody; worker_processes 2; error_log /usr/local/nginx/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 6000; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format combined_realip \'$remote_addr $http_x_forwarded_for [$time_local]\' \' $host "$request_uri" $status\' \' "$http_referer" "$http_user_agent"\'; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; include vhost/*.conf; } #检查一下是否存在语法问题 [root@Centos-1 conf]# /usr/local/nginx/sbin/nginx -t

创建vhost
定义多台虚拟机

[root@Centos-1 ~]# mkdir /usr/local/nginx/conf/vhost [root@Centos-1 ~]# vim /usr/local/nginx/conf/vhost/bbs.conf server { listen 80 default_server; server_name www.blog.aming2306.com; index index.html index.htm index.php; root /data/wwwroot/blog.aming2306.com; //虚拟主机目录 access_log /tmp/zrblog.com.log combined_realip; //配置虚拟主机的日志 location ~ .php$ { include fastcgi_params; fastcgi_pass unix:/tmp/zrblog.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/wwwroot/blog.aming2306.com$fastcgi_script_name; //虚拟主机解析地址 } }

启动服务

[root@Centos-1 ~]# service nginx start #将nginx加入到服务列表里 [root@Centos-1 ~]# chkconfig --add nginx #配置开机启动 [root@Centos-1 ~]# chkconfig nginx on

把解压后的jdk 移动并命令

[root@Centos-1 src]# mv jdk1.8.0_144 /usr/local/jdk1.8

编辑/etc/profile 文件配置环境变量

[root@Centos-1 src]# vim /etc/profile 把这段配置写到最后面: JAVA_HOME=/usr/local/jdk1.8/ JAVA_BIN=/usr/local/jdk1.8/bin JRE_HOME=/usr/local/jdk1.8/jre PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar #保存退出后,立即生效 [root@Centos-1 src]# source /etc/profile

检查配置是否生效

[root@Centos-1 jdk1.8]# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

把解压后的tomcat移动并重名

[root@Centos-1 src]# mv apache-tomcat-8.5.20 /usr/local/tomcat

启动tomcat

说明 直接运行 /usr/local/tomcat/bin/startup.sh命令即可

[root@Centos-1 src]# src]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/jdk1.8 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started. 用ps aux 命令查看一下有没有java进程

[root@Centos-1 ~]# ps aux |grep java root 26137 2.0 9.7 2566816 183920 pts/1 Sl 16:57 1:22 /usr/local/jdk1.8/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start root 26980 1.0 3.3 2055592 62312 pts/1 Sl 17:00 0:42 /usr/local/jdk1.8/jre/bin/java -Xms8m -Xmx32m -Dfile.encoding=UTF-8 -jar /data/wwwroot/zrblog/WEB-INF/plugins/plugin-core.jar 24662 44662 /data/wwwroot/zrblog/WEB-INF/db.properties /data/wwwroot/zrblog/WEB-INF/plugins/jars 54662 /data/wwwroot/zrblog 1.7.1 root 27132 0.0 0.0 112676 980 pts/0 R+ 18:04 0:00 grep --color=auto java
Tomcat监听的三个端口

[root@Centos-1 ~]# netstat -ntlp |grep java tcp6 0 0 :::8009 :::* LISTEN 56698/java tcp6 0 0 :::8080 :::* LISTEN 56698/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 56698/java

搭建zrlog

#下载zrlog [root@Centos-1src]# wget http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war #解压zrlog 说明 :把zrlog下载的包拷贝appBase里面,appBase支持自动解压war包的. 默认appBase是/usr/local/tomcat/webapps/下 [root@Centos-1 src]# cp zrlog-1.7.1-baaecb9-release.war /usr/local/tomcat/webapps/ # 解压完毕 [root@Centos-1 src]# ls /usr/local/tomcat/webapps/ docs examples host-manager manager ROOT zrlog-1.7.1-baaecb9-release zrlog-1.7.1-baaecb9-release.war #把解压后重命名 [root@Centos-1 src]# cd /usr/local/tomcat/webapps/ [root@Centos-1 webapps]# mv zrlog-1.7.1-baaecb9-release zrlog

创建好存放站点的目录

[root@Centos-1 ~]# mkdir-p/data/wwwroot/zrblog

拷贝站点内容到站点目录

[root@Centos-1 ~]# cp /usr/local/tomcat/webapps/zrlog/* /data/wwwroot/zrlog

就可以满足站点要求,继续进行下一步安装

mysql相关获取

需要先在远程mysql机器上创建可以用的用户名,指定访问地址

为了方便进入MySQL端,配置一个环境变量

vim/etc/profile 在末行添加 exportPATH=$PATH:/usr/local/mysql/bin/

登录mysql

[root@Centos-1 webapps]# mysql -uroot -pmysql1.1 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1 Server version: 5.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type \'help;\' or \'h\' for help. Type \'c\' to clear the current input statement.

创建 zrlog站点所需用户、库

mysql> create database zrlog; Query OK, 1 row affected (0.01 sec)

创建用户“wwwblog”密码为“blog”来源IP192.168.14.165,对zrblog库拥有所有权限

mysql> grant all on zrlog.* to \'wwwblog\'@\'192.168.14.165\' identified by \'zrlog1.1\'; Query OK, 0 rows affected (0.01 sec)

http://192.168.14.165/zrlog/

填写完成后,点击下一步

说名:管理密码:zrlog1.1; 网站标题和网站子标题随意定


安装完成点击查看

分享名称:搭建lnmp+tomcat+jdk环境与安装zrblog
转载注明:http://njwzjz.com/article/cggjig.html