Centos7 新服务器基础环境安装

简述:老服务器上有php项目和JAVA项目,所以,在新服务器上搭建 Nginx, Apache,tomact ;
基础环境 php7.1,jdk1.8 ;
所有软件包的分享地址:
链接:https://pan.baidu.com/s/1A8RZLBpBi2m8QG9EBHAQ2w
提取码:12vy
操作记录:
【jdk】
卸载安装操作系统原有的openjdk1. rpm -qa | grep java2.yum remove xxx安装sun 的jdk1.获取jdk 1.8 .tar.gz 安装包 ,安装包移动到/usr/local/2.cd /usr/local/ 解压安装包3.编辑 /etc/profilevim /etc/profile #内容如下,在最后一行添加export JAVA_HOME=/usr/local/jdk文件夹export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH4.source /etc/profile 使生效java -versionecho $JAVA_HOME 是空,个人总结 根据当前使用的用户的profile文件有关,我用的非root , 找到当前用户下的 .bash_profile 它是个隐藏文件 。我的当前用户是yuan;vim /home/yuan/.bash_profile把下方的再沾一遍:export JAVA_HOME=/usr/local/jdk文件夹export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATHsource 一下

Centos7 新服务器基础环境安装

文章插图
/etc/profile
【tomact】
特别简单,提前配置好jdk 解压tomact安装包,进入bin目录启动即可;./startup.sh #启动tom猫./shutdown.sh # 关闭tom猫
Centos7 新服务器基础环境安装

文章插图
查看8080端口
遇到的问题:8080端口一段时间后再查看关闭,访问无效 。看下localhost.xxxx-xx-xx.log
看日志的级别:
SEVERE > WARNING > INFO > CONFIG > FINE > FINER > FINEST

Centos7 新服务器基础环境安装

文章插图
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.gzcd apr-1.5.2 ./configure --prefix=/usr/local/apache/aprmake && make install安装:apr-util资源包查看上文百度网盘分享;tar zxvf apr-util-1.5.4.tar.gzcd apr-util-1.5.4./configure --prefix=/usr/local/apache/apr-util --with-apr=/usr/local/apache/aprmake && make install安装pcre:tar zxvf pcre-8.37.tar.gztar zxvf pcre-8.37.tar.gz./configuremake && 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=preforkmake && make installln -s /usr/local/apache/conf /etc/httpdln -s /usr/local/apache/bin/* /usr/sbin/touch /etc/init.d/httpdchmod 755 /etc/init.d/httpdservice httpd start; #起service httpd start; #停
Centos7 新服务器基础环境安装

文章插图
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 安装:资源包查看上文百度网盘分享; phptar -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.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmphp-fpm的启动、停止和重启:service php-fpm start#启动service php-fpm stop#停止service php-fpm restart#重启追加配置 httpd 解析php 必需品:LoadModule php7_modulemodules/libphp7.soAddType Application/x-httpd-php .php


推荐阅读