搭建 CentOS 6 服务器(5) - Java(Ant/Maven/Gradle)、PHP(php-fpm)
程序员文章站
2022-06-12 15:38:01
...
(一)Java
(1)JDK
下载安装
OracleJDK下载方法变更:
变更前
现在(URL里需要各版本的特殊hash值)
设置默认JDK
设置环境变量
确认JDK版本
开启SSLv3
导入GoDaddy证书
删除GoDaddy证书
(2)Ant
下载安装
设置环境变量
确认Ant版本
(3)Maven
下载安装
设置环境变量
确认Maven版本
(4)Gradle
下载安装
设置环境变量
确认Gradle版本
(二)PHP
安装依赖库
下载安装
配置PHP
设置环境变量
确认PHP版本
追加模块(以pgsql为例)
设置php-fpm
链接nginx和php-fpm
FastCGI访问量大时易出现502,交给apache处理比较好。
链接apache和php
(1)JDK
下载安装
# cd /usr/local/src # wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u76-b13/jdk-7u76-linux-x64.rpm -O jdk-7u76-linux-x64.rpm # rpm -ivh jdk-7u76-linux-x64.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar...
OracleJDK下载方法变更:
变更前
引用
wget --no-check-certificate --no-cookies \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
现在(URL里需要各版本的特殊hash值)
引用
wget --no-check-certificate --no-cookies \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
设置默认JDK
# alternatives --install /usr/bin/java java /usr/java/default/bin/java 776 # alternatives --config java There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/java/default/bin/java Enter to keep the current selection[+], or type selection number: 1
设置环境变量
# vi /etc/profile.d/java.sh #!/bin/bash JAVA_HOME=/usr/java/default/ PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME export CLASSPATH=. # chmod +x /etc/profile.d/java.sh # source /etc/profile.d/java.sh
确认JDK版本
# java -version java version "1.7.0_76" Java(TM) SE Runtime Environment (build 1.7.0_76-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode) # echo $JAVA_HOME /usr/java/default
开启SSLv3
# cd /usr/java/default/jre/lib/security # vi java.security #jdk.tls.disabledAlgorithms=SSLv3
导入GoDaddy证书
# cd /usr/local/src # wget -O gd_bundle-g2-g1.crt 'https://certs.godaddy.com/repository/gd_bundle-g2-g1.crt' # wget -O gdroot-g2_cross.crt 'https://certs.godaddy.com/repository/gdroot-g2_cross.crt' # wget -O gd_intermediate.crt 'https://certs.godaddy.com/repository/gd_intermediate.crt' # wget -O gd_cross_intermediate.crt 'https://certs.godaddy.com/repository/gd_cross_intermediate.crt' # cd /usr/java/default/jre/lib/security/ # cp cacerts cacerts_default # /usr/java/default/bin/keytool -list -keystore /usr/java/default/jre/lib/security/cacerts | grep -A 1 godaddy Enter keystore password: changeit godaddyclass2ca, Jan 21, 2005, trustedCertEntry, Certificate fingerprint (SHA1): 27:96:BA:E6:3F:18:01:E2:77:26:1B:A0:D7:77:70:02:8F:20:EE:E4 -- godaddyrootg2ca, Jul 19, 2014, trustedCertEntry, Certificate fingerprint (SHA1): 47:BE:AB:C9:22:EA:E8:0E:78:78:34:62:A7:9F:45:C2:54:FD:E6:8B # /usr/java/default/bin/keytool -import -trustcacerts -alias godaddybundleg2g1 -file /usr/local/src/gd_bundle-g2-g1.crt -keystore /usr/java/default/jre/lib/security/cacerts Enter keystore password: changeit Certificate was added to keystore # /usr/java/default/bin/keytool -import -trustcacerts -alias godaddyrootg2cross -file /usr/local/src/gdroot-g2_cross.crt -keystore /usr/java/default/jre/lib/security/cacerts Enter keystore password: changeit Certificate was added to keystore # /usr/java/default/bin/keytool -import -trustcacerts -alias godaddyintermediate -file /usr/local/src/gd_intermediate.crt -keystore /usr/java/default/jre/lib/security/cacerts Enter keystore password: changeit Certificate was added to keystore # /usr/java/default/bin/keytool -import -trustcacerts -alias godaddycrossintermediate -file /usr/local/src/gd_cross_intermediate.crt -keystore /usr/java/default/jre/lib/security/cacerts Enter keystore password: changeit Certificate was added to keystore # /usr/java/default/bin/keytool -list -keystore /usr/java/default/jre/lib/security/cacerts | grep -A 1 godaddy Enter keystore password: changeit godaddyintermediate, Nov 13, 2015, trustedCertEntry, Certificate fingerprint (SHA1): 7C:46:56:C3:06:1F:7F:4C:0D:67:B3:19:A8:55:F6:0E:BC:11:FC:44 -- godaddybundleg2g1, Nov 13, 2015, trustedCertEntry, Certificate fingerprint (SHA1): 27:AC:93:69:FA:F2:52:07:BB:26:27:CE:FA:CC:BE:4E:F9:C3:19:B8 -- godaddyrootg2cross, Nov 13, 2015, trustedCertEntry, Certificate fingerprint (SHA1): 34:0B:28:80:F4:46:FC:C0:4E:59:ED:33:F5:2B:3D:08:D6:24:29:64 godaddycrossintermediate, Nov 13, 2015, trustedCertEntry, Certificate fingerprint (SHA1): DE:70:F4:E2:11:6F:7F:DC:E7:5F:9D:13:01:2B:7E:68:7A:3B:2C:62 -- godaddyclass2ca, Jan 21, 2005, trustedCertEntry, Certificate fingerprint (SHA1): 27:96:BA:E6:3F:18:01:E2:77:26:1B:A0:D7:77:70:02:8F:20:EE:E4 -- godaddyrootg2ca, Jul 19, 2014, trustedCertEntry, Certificate fingerprint (SHA1): 47:BE:AB:C9:22:EA:E8:0E:78:78:34:62:A7:9F:45:C2:54:FD:E6:8B
删除GoDaddy证书
# /usr/java/default/bin/keytool -delete -alias godaddyig2 -keystore /usr/java/default/jre/lib/security/cacerts
(2)Ant
下载安装
# cd /usr/local/src # wget http://mirrors.cnnic.cn/apache//ant/binaries/apache-ant-1.9.4-bin.zip # unzip apache-ant-1.9.4-bin.zip # mv apache-ant-1.9.4/ /opt/ant # ln -s /opt/ant/bin/ant /usr/bin/ant
设置环境变量
# vi /etc/profile.d/ant.sh #!/bin/bash ANT_HOME=/opt/ant PATH=$ANT_HOME/bin:$PATH export PATH ANT_HOME # chmod +x /etc/profile.d/ant.sh # source /etc/profile.d/ant.sh
确认Ant版本
# ant -version Apache Ant(TM) version 1.9.4 compiled on April 29 2014 # echo $ANT_HOME /opt/ant
(3)Maven
下载安装
# cd /usr/local/src # wget http://mirrors.cnnic.cn/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip # unzip apache-maven-3.2.5-bin.zip # mv apache-maven-3.2.5/ /opt/maven # ln -s /opt/maven/bin/mvn /usr/bin/mvn
设置环境变量
# vi /etc/profile.d/maven.sh #!/bin/bash MAVEN_HOME=/opt/maven PATH=$MAVEN_HOME/bin:$PATH export PATH MAVEN_HOME # chmod +x /etc/profile.d/maven.sh # source /etc/profile.d/maven.sh
确认Maven版本
# mvn -version Apache Maven 3.2.5 ..... # echo $MAVEN_HOME /opt/maven
(4)Gradle
下载安装
# cd /usr/local/src # wget https://downloads.gradle.org/distributions/gradle-3.0-bin.zip # unzip gradle-3.0-bin.zip # mv gradle-3.0/ /opt/gradle # ln -s /opt/gradle/bin/gradle /usr/bin/gradle
设置环境变量
# vi /etc/profile.d/gradle.sh #!/bin/bash GRADLE_HOME=/opt/gradle PATH=$GRADLE_HOME/bin:$PATH export PATH GRADLE_HOME # chmod +x /etc/profile.d/gradle.sh # source /etc/profile.d/gradle.sh
确认Gradle版本
# gradle -version Gradle 3.0 ..... # echo $GRADLE_HOME /opt/gradle
(二)PHP
安装依赖库
# yum -y install bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libc-client-devel.i686 libc-client-devel libmcrypt-devel libxml2-devel krb5-devel
下载安装
# cd /usr/local/src # wget -O php-5.6.6.tar.gz http://cn2.php.net/get/php-5.6.6.tar.gz/from/this/mirror # tar -zxvf php-5.6.6.tar.gz # cd php-5.6.6 # ./configure --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-zlib-dir --with-regex --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-soap --enable-sockets --with-xmlrpc --enable-zip --with-zlib --enable-inline-optimization --enable-mbregex --enable-opcache --enable-fpm --with-apxs2=/usr/local/apache2/bin/apxs --prefix=/usr/local/php # make # make install
配置PHP
# cd /usr/local/php/lib # cp /usr/local/src/php-5.6.6/php.ini-development ./php.ini # vi php.ini short_open_tag = On disable_functions = exec,passthru,shell_exec,system,proc_open,popen expose_php = Off display_errors = Off display_startup_errors = Off log_errors = On
设置环境变量
# vi /etc/profile.d/php.sh #!/bin/bash PHP_HOME=/usr/local/php PATH=$PHP_HOME/bin:$PATH export PATH PHP_HOME export CLASSPATH=. # chmod +x /etc/profile.d/php.sh # source /etc/profile.d/php.sh
确认PHP版本
# php -v PHP 5.6.6 (cli) (built: Mar 6 2015 16:57:48) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
追加模块(以pgsql为例)
# /usr/local/php/bin/php -m [PHP Modules] bcmath ...... zlib [Zend Modules] # php -m | grep pgsql # cd /usr/local/src/php-5.6.6/ext/pgsql/ # phpize # ./configure --with-pgsql=/usr/local/pgsql # make # make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ # vi /usr/local/php/lib/php.ini extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/" extension=pgsql.so # php -m | grep pgsql
设置php-fpm
# cp /usr/local/src/php-5.6.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # cd /usr/local/php/etc # cp php-fpm.conf.default php-fpm.conf # chmod +x php-fpm # service php-fpm start # service php-fpm status
链接nginx和php-fpm
# vi /usr/local/nginx/conf/nginx.conf location ~ \.php$ { root /usr/local/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
FastCGI访问量大时易出现502,交给apache处理比较好。
引用
location ~ .(php)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:88;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:88;
}
链接apache和php
# vi /usr/local/apache2/conf/httpd.conf LoadModule php5_module modules/libphp5.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> DirectoryIndex index.php AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
上一篇: 解放双手懒人神器,科语C602扫地机器人
下一篇: CentOS 安装 ELK