




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
RedHat Server7.1安装与配置从RHEL7开始,使用systemctl工具来管理服务程序,包括了service和chkconfigrootrhel7 # systemctl list-unit-files|grep enabled启动一个服务:systemctl start firewalld.service关闭一个服务:systemctl stop firewalld.service重启一个服务:systemctl restart firewalld.service显示一个服务的状态:systemctl status firewalld.service在开机时启用一个服务:systemctl enable firewalld.service在开机时禁用一个服务:systemctl disable firewalld.service查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?查看已启动的服务列表:systemctl list-unit-files|grep enabled一、安装通过iso文件进行安装,最小安装时,ifconfig等命令是不可使用的。可以通过“ip link show”、“ip address”等命令查看IP地址。(一)网卡的配置RedHat7对网卡的命名有了很大不同,可以参考如下命名规则:本人在虚拟机上安装RedHat Server7.1后,网卡被命名为enp0s3,网卡的配置文件为/etc/sysconfig/network-scripts/ifcfg-enp0s3。因此IP地址、子网掩码、网关、dns等均可在这个文件中进行配置。下图展示了一个配置文件:当前是static(静态IP地址),如果要使用dhcp,则修改:BOOTPROTO=dhcpONBOOT=yes #开启自动启用网络连接,如果设置为no,则启动系统后网卡不能链接IPADDR=20 #设置IP地址PREFIX=27 #设置子网掩码GATEWAY=93 #设置网关DNS1=8 #设置主DNSDNS2=xxx.xxx.xxx.xxx #设置备DNS完成后service network restart #重启网络(二)ssh启动#/bin/systemctl start sshd.service(三)添加用户#groupadd webmanager 添加管理网站的组添加用户名为:webmanager,属组:webmanage,密码:nts20080808,主目录:/home/website/#useradd webmanger -g webmanage p nts20080808 -d /home/website/修改用户登录名:#usermod -l webmanager webmanger 将用户名webmanger修改为webmanager修改用户webmanger登录密码:#passwd webmanger(四)设置iso文件为本地安装源1.上传iso文件将radHat Server7的iso文件rhel-server-7.1-x86_64-dvd.iso上传到服务器的/home/website/download/iso目录下。2.挂载iso文件将iso文件挂载为/media/cdrom#mkdir /media/cdrom# cd /media/cdrom#ls 可以看到镜像中的文件已经存在了,说明挂载成功备注:umount /media/cdrom #卸载系统镜像3.设置开机自动挂载系统镜像文件vi /etc/fstab #添加代码(/home/website)。实现开机自动挂载 :wq! #保存退出 备注:iso9660使用df -T 查看设备4.配置本地yum源#cd /etc/yum.repos.d#touch rhel-media.repo 建立yum配置文件#vi rhel-media.repo添加以下内容:rhel-media name=Red Hat Enterprise Linux 7.1 #自定义名称 baseurl=file:/media/cdrom #本地光盘挂载路径 enabled=1 #启用yum源,0为不启用,1为启用 gpgcheck=1 #检查GPG-KEY,0为不检查,1为检查 gpgkey=file:/media/cdrom/RPM-GPG-KEY-redhat-release #GPG-KEY路径如下图所示:#:wq 保存退出5.使用yum安装软件#yum clean all 清除yum缓存#yum makecache 缓存本地yum源中的软件包信息#yum install 软件包名称 (如:yum install httpd)(五)设置本地字符集#vi /etc/environment添加:LC_ALL=”zh_CN.GBK”LANG=”zh_CN.GBK”wq保存退出#source /etc/environment二、SSH升级及配置(一)升级openssh系统自带的openssh是6.6版的,现在准备升级到最新的6.8版。先到openssh下载最新版。本次安装需要zlib、openssl库。因此需要先将这些软件的最新版上传到服务器。1.zlib安装先到/zlib/下载最新的zlib-1.2.8.tar.gz安装包,并上传到服务器,并解压。#tar zxvf zlib-1.2.8.tar.gz#./configure - -prefix=/usr/local/zlib1.2.8#make#make install以上命令是将zlib安装到/usr/local/zlib1.2.8目录。2.升级openssl到1.0.2a版本先到/下载最新的openssl-1.0.2a.tar.gz,上传到安装服务器并解压。#tar zxvf openssl-1.0.2a.tar.gz#cd openssl-1.0.2a#./config prefix=/usr/local/openssl1.0.2a -shared 一定记得加上-shared选项, 否则openssh编译的时候会找不到新安装的openssl的library, 会报错: openssl的 header和library版本不匹配#make#make test#make installmake test(这一步很重要哦!是进行 SSL 加密协议的完整测试,如果出现错误就要一定先找出哪里的原因,否则一味继续,可能最终导致 SSH 不能使用,后果很严重的!)vi /etc/profile,添加PATH=/usr/local/openssl1.0.2a/bin:$PATHexport PATH添加完成后保存,source /etc/profile#openssl version a可以看到,openssl已经是最新版了。3. 安装升级openssh6.8安装新版之前先检测一下系统原来的版本,然后将其删除。#rpm qa | grep openssh#rpm e openssh -nodeps#rpm e openssh-clients nodeps#rpm e open-server nodeps删除完成后,到官方网站下载最新的openssh-6.8p1.tar.gz,上传到服务器并解压缩。先将zlib、openssl1.0.2的库文件路径添加到库搜索路径中。#echo “/usr/local/zlib1.2.8/lib” /etc/ld.so.conf.d/dyninst-x86_64.conf#echo “/usr/local/openssl1.0.2a/lib” /etc/ld.so.conf.d/dyninst-x86_64.conf#sudo ldconfig 这步很重新,一定不要忘记执行安装openssh6.8p1:#tar zxvf openssh-6.8p1.tar.gz#cd openssh-6.8p1执行配置命令后,显示:#make & make install以上安装方法是将openssl安装到/usr/local/openssh6.8.p1目录下,配置文件是/etc/ssh/sshd_config。提示没有sshd这个服务。下面我们将其添加到service服务中进行管理。进入用openssh6.8的源文件目录,即之前解压的目录,执行:#cp p contrib/redhat/ sshd.init /etc/init.d/sshd (redhat系统)#chmod +x /etc/init.d/sshd#chkconfig -add sshd经过以上处理,如果仍然不能启动sshd,则复制libcrypto.so.1.0.0到/usr/lib64/dyninst,否则启动sshd时会提示找不到这个库。#cp /usr/local/openssl1.0.2a/lib/libcrypto.so.1.0.0 /usr/lib64/dyninst/#service sshd start 启动sshd服务。如果启动过程没有反应或没有成功提示,则vi /etc/init.d/sshd,将SSHD的值设置为实际安装Openssh的目录。如下:三、jdk8u45的安装#tar -zxvf jdk-8u45-linux-x64.tar.gz#mv jdk1.8.45 /usr/local#vi /etc/profile添加:JAVA_HOME=/usr/local/jdk1.8.0_45JRE_HOME=$JAVA_HOME/jreCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATHExport JAVA_HOME JRE_HOME CLASSPATH PATH#source /etc/profile四、MySql5.6.24的安装与配置(一)Cmake的安装由于安装MySql5.6.24需要用到cmake程序,因此需要安装cmake。到/download/ 下载最新版的cmake-3.2.2.tar.gz,上传到服务器。#tar -zxvf cmake-3.2.2.tar.gz#cd cmake-3.2.2如果原来没有安装过cmake,则:#./bootstrap#gmake#gmake install安装过程中出现如下错误:缺少gcc,gcc+环境#yum y install gcc#yum y install gcc-c+再次bootstrap,正常了。如果本机上存在cmake,想安装一个新版本,则:#cmake .#gmake#gmake install(二)安装Mysql-5.6.241.源码安装Mysql5.6.24#tar zxvf mysql-5.6.24.tar.gz#cd mysql-5.6.24用源码编译安装Mysql5.6.24:#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/home/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306-DENABLE_DOWNLOADS=1此过程中出现“Curses library not found. Please install appropriate package,”,说明缺少curses-devel包,我们需要安装它们。下载如下rpm包,注意它们的版本要一致,否则无法安装(如果配置了本地yum源,则可以用:yum y install ncurses-devel安装)。先检查系统是否安装有相应的包:#rpm qa | grep ncurses有的话一一删除。然后再进行安装#rpm ivh ncurses-base-5.9-12.20130511.fc20.noarch.rpm#rpm ivh ncurses-libs-5.9-12.20130511.fc20.x86_64.rpm#rpm ivh ncurses-devel-5.9-12.20130511.fc20.x86_64.rpm#rm CMakeCache.txt 删除之前生成的文件然后再cmake编译安装Mysql5.6.24:#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/home/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306-DENABLE_DOWNLOADS=1这次编译终于通过了。#make#make install注意:如果需要重装mysql,在/usr/local/src/mysql-5.6.12在执行下make install就可以了,不需要再cmake和make2.清除安装临时文件# make clean3.修改目录拥有者# chown -Rf mysql:mysql /usr/local/mysql-5.6.24# chown -Rf mysql:mysql /home/mysql4.进入mysql执行程序的安装路径# cd /usr/local/mysql-5.6.245.执行初始化配置脚本,创建系统自带的数据库和表(注意路径/home/mysql/data需要换成你自定定义的数据库存放路径)# scripts/mysql_install_db -user=mysql -datadir=/home/mysql/data执行以上命令时出现:scripts/mysql_install_db: /usr/bin/perl: 坏的解释器: 没有那个文件或目录错误,原因是:系统是64位,而mysql是32位。解决办法:安装32位环境,或者安装64位myql。或者:yum -y install perl perl-devel,再执行scripts/mysql_install_db,出现以下错误提示:FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:则yum -y install perl-Module-*问题终于解决。#初始化脚本在/usr/local/mysql/下生成了配置文件f,需要更改该配置文件的所有者:# chown -Rf mysql:mysql /usr/local/mysql注意:(1)Tips:在启动MySQL服务时,会按照一定次序搜索f,先在/etc目录下找,找不到则会搜索mysql程序目录下是否有f;(2)需要注意CentOS 6.4版操作系统的最小安装完成后,即使没有安装mysql,在/etc目录下也会存在一个f文件,建议将此文件更名为其他的名字,否则该文件会干扰源码安装的MySQL的正确配置,造成无法启动。修改/etc/f操作如下:# mv /etc/f /etc/f.bak# 当然也可以删除掉/etc/f这个文件:# rm /etc/f(3)如果你需要用于生产环境,不要急着做下面的mysql启动操作。建议把上一步骤中mysql初始化生成的/usr/local/mysql/f删除,然后把你优化好的mysql配置文件f放到/etc下。(这是我做mysql主从复制和mysql优化的经验!)6.复制服务启动脚本# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql7.启动MySQL服务# service mysql start8.设置开机自动启动服务# chkconfig mysql on9.登录并修改MySQL用户root的密码#vi /etc/profile将/usr/local/mysql-5.6.24/bin添加至PATH中。#source /etc/profile# mysql -u rootmysql use mysql;mysql GRANT ALL PRIVILEGES ON *.* TO root% IDENTIFIED BY 123456;mysql update user set Password = password(123456) where User=root;mysql flush privileges;mysql exit;10.检测下上一步MySQL用户root密码是否生效:rootyimiju etc# mysql -u root pnts20080808 执行:再次登录,输入正常密码后终于成功了。 rootyimiju # mysql -u root -pEnter password: 这里提示时输入你设置的mysql root帐号密码#登录成功有如下提示:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 422Server version: 5.6.12-log Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type help; or h for help. Type c to clear the current input statement.mysql 11.(可选)运行安全设置脚本,强烈建议生产服务器使用:rootyimiju # /usr/local/mysql/bin/mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, well need the currentpassword for the root user. If youve just installed MySQL, andyou havent set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): OK, successfully used password, moving on.Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.You already have a root password set, so you can safely answer n.Change the root password? Y/n n-这里输入n . skipping.By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? Y/n Y-这里输入Y . Success!Normally, root should only be allowed to connect from localhost. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? Y/n n-这里输入n . skipping.By default, MySQL comes with a database named test that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? Y/n Y-这里输入Y - Dropping test database.ERROR 1008 (HY000) at line 1: Cant drop database test; database doesnt exist . Failed! Not critical, keep moving. - Removing privileges on test database. . Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? Y/n Y-这里输入Y . Success!All done! If youve completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!Cleaning up.12.重启服务器,检测mysql是否能开机自动启动rootyimiju # reboot五、安装配置Nginx(一)安装Nginx到下载最新的1.9.0版。#tar zxvf nginx注意:以上配置中的with-pcre、-with-openssl、-with-zlib后的文件夹是源码文件夹,不是安装文件夹,如果改成安装文件夹,make时会出现错误。#make#make install(二)配置Nginx#vi /usr/local/nginx-1.9.0/conf/nginx.confworker_processes 8 #设置跟cpu核数一样就行worker_rlimit_nofile 309600;events worker_connections 309600; use epoll; server listen 80; #server_name localhost; server_name 20; 这里根据情况填写,如 charset utf-8; #access_log logs/host.access.log main; location / #配置web站点在服务器上的文件位置 root /home/website/; index index.html index.htm index.jsp shouye.jsp index.action; #动态文件交由resin或tomcat处理 location .(jsp|jspx|action|do)?$ 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 :8080; #resin服务的位置,如果是tomcat也行 #静态文件缓存时间 location .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|docx|ppt|xls|xlsx|mp3|wma)$ expires 30d; location .*.(js|css)?$ expires 1h; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html root html; # proxy the PHP scripts to Apache listening on :80 # #location .php$ # proxy_pass ; #六、rhel7的防火墙配置1.添加tcp端口#firewall-cmd -zone=public -add-port=8080/tcp以上这种添加的方法只是暂时的,重新启动系统后无效。添加参数permanent后,可以变成永久生效。#firewall-cmd -zone=public -permanent -add-port=8080/tcp-增加zone public开放http servicerootlocalhost zones# firewall-cmd -zone=public -add-service=httpsuccess rootlocalhost zones# firewall-cmd -permanent -zone=internal -add-service=httpsuccessrootlocalhost zones# firewall-cmd -reloadsuccessrootlocalhost zones# firewall-cmd -zone=internal -add-port=443/tcpsuccess rootlocalhost zones# firewall-cmd -zone=internal -list-servicesdhcpv6-client http ipp-client mdns samba-client ssh防火墙中的一切都与一个或者多个区域相关联。配置之后,RHEL 7服务器正常会在公共区域,但是你也许会想将它放置在另一个网络配置防火墙访问。这时使用firewall-cmd get-default-zone命令,该命令显示你的服务器在哪一个网络。如果你想查看配置特定网络的详细信息,你可以使用列表2中的firewall-cmd zone=zonename list-all命令。列表2.rootrhelserver # firewall-cmd get-default-zonepublicrootrhelserver # firewall-cmd get-zones block dmz drop external home internal public trusted work rootrhelserver # firewall-cmd zone=public list-all public (default, active) interfaces: ens33 sources: services: dhcpv6-client sander ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:改变当前区域并不难:使用firewall-cmd set-default-zone=home命令,该命令可用于从公共网络到家庭网络制定一个默认网络。服务和其他构件在区域中有一些基本的构件块,其中服务是最重要的。防火墙使用管理员创建在/usr/lib/firewalld/services(系统默认服务) 和/etc/firewalld/services文件下的XML文件,配置的自身服务集。XML文件时通过列表3中的例子创建的。列表3.rootrhelserver services# cat ftp.xml FTP FTP is a protocol used for remote file transfer. If you plan to make your FTP server publicly available, enable this option. You need thevsftpd package installed for this option to be useful. 每一个服务定义都需要一个简短的名字、描述和端口网络用于指定需要使用的协议、端口和模块名。列表4.以下是创建防火墙服务的例子rootrhelserver services# cat sander.xml Sander Sander is a random service to show how service configuration works. 一旦你有了正确的服务文件,使用以下代码复制它。firewall-cmd list-services命令显示从你服务器上的所有可以找到的服务列表。如果要增加服务则输入firewall-cmd add-service yourservice将服务放到默认网络上,或者是使用zone=zonename选择特定网络。下面描述了它如何工作:1.使用firewall-cmd zone=public list-all命令,显示当前公共区域配置。 rootrhelserver # firewall-cmd zone=public list-all public (default, active) interfaces: ens33 sources: services: dhcpv6-client ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:2.命令firewall-cmd zone=public add-service=ftp,在Linux防火墙的公共区域上添加FTP服务。3.重复步骤1检查FTP服务是否成功添加,你将看到服务列表。4.重启服务器,执行步骤1.你将看到FTP服务消失了,在防火墙中,没有永久的事物,除非你使用了permanent选项。5.将FTP服务添加到公共网络上,并设为永久设置,该步骤使用firewall-cmd permanent zone=public add-service=ftp命令。重启之后该设置生效。6.输入firewall-cmd reload提交所有规则同时重载防火墙。使用permanent设置永久防火墙选项是非常重要的。打破规则配置防火墙配置服务是推荐的方式,它可以轻而易举地提供防火墙的全局概览。但是如果你想在/etc/firewalld/service文件下自己定义服务,在不使用该文件的情况下也可添加端口。使用firewall-cmd p
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 情景交际用语课件
- 悄悄变化的我课件简介
- 幼儿园大班心脏教育活动策划方案
- 开学第一天主题班会活动方案
- 小班上学期老师个人工作方案
- 电磁感应试题及答案
- 七夕餐厅营销活动方案策划
- 定向选调面试题及答案
- 后勤管理考试题及答案
- 职业暴露试题及答案
- GA/T 2133.1-2024便携式微型计算机移动警务终端第1部分:技术要求
- 农药使用管理制度
- 班组长成本绩效管理能力考试题库-下(判断题)
- 呼吸机断电的应急演练
- 视觉传达设计保研面试问题
- 慰问品采购项目供货方案
- 医院护理培训课件:《注射安全》
- 5G智慧执法解决方案
- 2024年南宁铁路局招聘笔试参考题库附带答案详解
- (完整)中医症候积分量表
- 公共管理研究方法 课件 第11、12章 定性比较分析、写作
评论
0/150
提交评论