簡述:老服務器上有php項目和JAVA項目,所以,在新服務器上搭建 Nginx, Apache,tomact ;
基礎環境 php7.1, jdk1.8 ;
所有軟件包的分享地址:
鏈接:https://pan.baidu.com/s/1A8RZLBpBi2m8QG9EBHAQ2w
提取碼:12vy
操作記錄:
【jdk】
卸載安裝操作系統原有的openjdk
1. rpm -qa | grep java
2.yum remove xxx
安裝sun 的jdk
1.獲取jdk 1.8 .tar.gz 安裝包 ,安裝包移動到/usr/local/
2.cd /usr/local/ 解壓安裝包
3.編輯 /etc/profile
vim /etc/profile #內容如下,在最后一行添加
export JAVA_HOME=/usr/local/jdk文件夾
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
4.source /etc/profile 使生效
java -version
echo $JAVA_HOME 是空 ,個人總結 根據當前使用的用戶的profile文件有關,
我用的非root , 找到當前用戶下的 .bash_profile 它是個隱藏文件。我的當前用戶是yuan;
vim /home/yuan/.bash_profile
把下方的再沾一遍:
export JAVA_HOME=/usr/local/jdk文件夾
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
source 一下

/etc/profile
【tomact】
特別簡單,提前配置好jdk 解壓tomact安裝包,進入bin目錄啟動即可;
./startup.sh #啟動tom貓
./shutdown.sh # 關閉tom貓

查看8080端口
遇到的問題:8080端口一段時間后再查看關閉,訪問無效。看下localhost.xxxx-xx-xx.log
看日志的級別:
SEVERE > WARNING > INFO > CONFIG > FINE > FINER > FINEST

localhost_log日志
執行: killall java ,干掉所有java相關;
重新進入 bin 目錄下 啟動tom貓即可;
【httpd】
yum install gcc gcc-c++ make wget
yum install zlib-devel openssl-devel
yum install -y perl perl-devel
安裝:apr 資源包查看上文百度網盤分享;
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apache/apr
make && make install
安裝:apr-util 資源包查看上文百度網盤分享;
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apache/apr-util --with-apr=/usr/local/apache/apr
make && make install
安裝pcre:tar zxvf pcre-8.37.tar.gz
tar zxvf pcre-8.37.tar.gz
./configure
make && make install
安裝apache : 資源包查看上文百度網盤分享;
cd /usr/local/src/
tar zxvf httpd-2.4.17.tar.gz
./configure --prefix=/usr/local/apache
--with-apr=/usr/local/apache/apr/bin/apr-1-config
--with-apr-util=/usr/local/apache/apr-util/bin/apu-1-config
--enable-module=so
--enable-mods-shared=all
--enable-deflate
--enable-expires
--enable-headers
--enable-cache
--enable-file-cache
--enable-mem-cache
--enable-disk-cache
--enable-mime-magic
--enable-authn-dbm
--enable-vhost-alias
--enable-so
--enable-rewrite
--enable-ssl
--with-mpm=prefork
make && make install
ln -s /usr/local/apache/conf /etc/httpd
ln -s /usr/local/apache/bin/* /usr/sbin/
touch /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
service httpd start; #起
service httpd start; #停

apache端口改為了81
【php】安裝依賴包:
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel
安裝:資源包查看上文百度網盤分享; php tar -zxvf php-7.1.0.tar.gz
cd php-7.1.0
編譯:
./configure
--prefix=/usr/local/php
--with-config-file-path=/etc
--with-apxs2=/usr/local/apache/bin/apxs
--enable-fpm
--enable-inline-optimization
--disable-debug
--disable-rpath
--enable-shared
--enable-soap
--with-libxml-dir
--with-xmlrpc
--with-openssl
--with-mcrypt
--with-mhash
--with-pcre-regex
--with-sqlite3
--with-zlib
--enable-bcmath
--with-iconv
--with-bz2
--enable-calendar
--with-curl
--with-cdb
--enable-dom
--enable-exif
--enable-fileinfo
--enable-filter
--with-pcre-dir
--enable-ftp
--with-gd
--with-openssl-dir
--with-jpeg-dir
--with-png-dir
--with-zlib-dir
--with-freetype-dir
--enable-gd-native-ttf
--enable-gd-jis-conv
--with-gettext
--with-gmp
--with-mhash
--enable-json
--enable-mbstring
--enable-mbregex
--enable-mbregex-backtrack
--with-libmbfl
--with-onig
--enable-pdo
--with-MySQLi=mysqlnd
--with-pdo-mysql=mysqlnd
--with-zlib-dir
--with-pdo-sqlite
--with-readline
--enable-session
--enable-shmop
--enable-simplexml
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-wddx
--with-libxml-dir
--with-xsl
--enable-zip
--enable-mysqlnd-compression-support
--with-pear
--enable-opcache
安裝:make && make install
配置環境變量: vim /etc/profile 追加到末尾
######################php7.1#######################
export PATH=/usr/local/php/bin:$PATH
保存后刷新環境變量:
source /etc/profile #更新
查看php版本:php -v
現在的PHP沒有.ini文件和配置文件,還需要配置PHP-FPM:
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
php-fpm的啟動、停止和重啟:
service php-fpm start #啟動
service php-fpm stop #停止
service php-fpm restart #重啟
追加配置 httpd 解析php 必需品:
LoadModule php7_module modules/libphp7.so
AddType Application/x-httpd-php .php

libphp7.so

.php

dir_module
【nginx】
1.tra -zxvf nginx-1.13.7.tar.gz #解壓nginx包
2./configure --prefix=/usr/local/nginx #生成nginx 目錄可自定義名稱
3.make
4.make install
5. /usr/local/nginx/sbin/nginx #啟
6./usr/local/nginx/sbin/nginx #重新加載nginx 修改后的配置
7.nginx 訪問info.php總是下載php測試文件:
把字節流類型改成html 類型; 如下圖a
8. 增加php解析模塊:如圖 b

a 訪問php測試文件提示下載

b nginx解析php必需品
防止以后再用時忘記,整理成筆記方便以后拿來主義。