下載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
標題URL:http://m.newbst.com/article6/cggjig.html
成都網站建設公司_創新互聯,為您提供外貿網站建設、關鍵詞優化、網站收錄、云服務器、自適應網站、App開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯