聚热网 旅游 phpnow卸载

phpnow卸载

phpnow卸载

phpnow卸载

在企业运维管理中,管理IP地址通常是一项挑战,有的采用Excel管理、有的用在线共享文档管理,这两个管理方式都在解决2个问题:1)记录IP地址信息;2)多人协作;今天介绍如何安装和使用开源的IP地址管理工具—“phpIPAM”,并在文章内详解介绍部署过程。

phpIPAM概述

phpIPAM是一个开源WebIP地址管理应用程序(IPAM)。其目标是提供轻便、现代且有用的IP地址管理。它是基于php的应用程序,具有MySQL数据库后端,使用jQuery库、ajax和HTML5/CSS3功能,其功能清单如下:

IPv4/IPv6IP地址管理;部分/子网管理,VLAN管理、VRF管理;自动显示子网的可用空间;可视化子网展示;自动子网扫描/IP状态检查;PowerDNS集成;网络地址转换支持;机架管理;域认证(AD、LDAP、Radius);设备/设备类型管理;IP请求模块;IPv4/IPv6计算器;自定义字段支持;RESTApi;服务器规划

服务器名称

IP地址

硬件配置

用途

mgmt-ipam

192.168.10.100

2C/4G/80G

服务器

环境及软件版本信息

软件名称

版本

备注

RockyLinux

8.8

推荐使用高版本操作系统。

Nginx

1.22.x

RockyLinux提供的最高版本。

PHP

7.4.x

phpIPAM支持的最新版本。

phpIPAM

1.5.x

最新版本。

mySQL

8.0.x

RockyLinux提供的最高版本。

安装基础环境软件

首先,修改系统默认的Nginx和php版本。

sudodnfmoduleswitch-tophp:7.4nginx:1.22

再安装所需的软件包。

sudodnfinstall-ymysql-servernginxphp-fpmphp-cliphp-gdphp-commonphp-ldapphp-pdophp-pearphp-snmpphp-xmlphp-mbstringphp-gmpphp-jsonphp-mysqlndgitMySQL数据库部署

设置MySQL自启动和启动服务,完成MySQL数据库的初始化工作。

sudosystemctlenable--nowmysqld

对MySQL数据库进行初始化,并配置root密码。

sudomysql_secure_installation

SecuringtheMySQLserverdeployment.\n\nConnectingtoMySQLusingablankpassword.\n#建立密码验证插件,选择“y”\nVALIDATEPASSWORDCOMPONENTcanbeusedtotestpasswords\nandimprovesecurity.Itchecksthestrengthofpassword\nandallowstheuserstosetonlythosepasswordswhichare\nsecureenough.WouldyouliketosetupVALIDATEPASSWORDcomponent?\n\nPressy|YforYes,anyotherkeyforNo:y\n\n#选择密码规则,选择“0”,密码大于等于8位\nTherearethreelevelsofpasswordvalidationpolicy:\n\nLOWLength>=8\nMEDIUMLength>=8,numeric,mixedcase,andspecialcharacters\nSTRONGLength>=8,numeric,mixedcase,specialcharactersanddictionaryfile\n\nPleaseenter0=LOW,1=MEDIUMand2=STRONG:0\nPleasesetthepasswordforroothere.\n\nNewpassword:\n\nRe-enternewpassword:\n\n#提示是否继续使用此密码规则,选择“y”\nEstimatedstrengthofthepassword:100\nDoyouwishtocontinuewiththepasswordprovided?(Pressy|YforYes,anyotherkeyforNo):y\n\n#删除匿名用户,选择“y”\nBydefault,aMySQLinstallationhasananonymoususer,\nallowinganyonetologintoMySQLwithouthavingtohave\nauseraccountcreatedforthem.Thisisintendedonlyfor\ntesting,andtomaketheinstallationgoabitsmoother.\nYoushouldremovethembeforemovingintoaproduction\nenvironment.\n\nRemoveanonymoususers?(Pressy|YforYes,anyotherkeyforNo):y\nSuccess.\n\n#禁止root远程登录,选择“y”\nNormally,rootshouldonlybeallowedtoconnectfrom\n'localhost'.Thisensuresthatsomeonecannotguessat\ntherootpasswordfromthenetwork.\n\nDisallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):y\nSuccess.\n\n#删除测试数据库,选择“y”\nBydefault,MySQLcomeswithadatabasenamed'test'that\nanyonecanaccess.Thisisalsointendedonlyfortesting,\nandshouldberemovedbeforemovingintoaproduction\nenvironment.\n\nRemovetestdatabaseandaccesstoit?(Pressy|YforYes,anyotherkeyforNo):y\n-Droppingtestdatabase...\nSuccess.\n\n-Removingprivilegesontestdatabase...\nSuccess.\n\n#重新加载权限表,选择“y”\nReloadingtheprivilegetableswillensurethatallchanges\nmadesofarwilltakeeffectimmediately.\n\nReloadprivilegetablesnow?(Pressy|YforYes,anyotherkeyforNo):y\nSuccess.\n\nAlldone!创建phpIPAM数据库和用户

此步骤并不是必须的,后续的安装向导中可以使用Root用户自动创建。

mysql-uroot-p\n\ncreatedatabasephpipam;\nCREATEUSER'phpipam'@'%'IDENTIFIEDBY'StrongPass123!';\nGRANTALLPRIVILEGESON*.*TO'phpipam'@'%'WITHGRANTOPTION;配置并启动php-fpm环境

修改正确的时区,以使php警告和其他与时间相关的功能正确显示时间。

sudosed-i"s/^;date.timezone=/date.timezone=Asia\\/Shanghai/g"/etc/php.ini

启动php-fpm服务。

sudosystemctlenable--nowphp-fpm配置Nginx服务器

这里推荐使用Nginx作为Web服务器,因为Nginx的速度更快,配置和管理SSL证书更容易。针对phpIPAM,我们可以使用两种不同的配置:

选项1:使用80端口提供服务,支持通过IP或域名访问

server{\nlisten80;\nserver_name_;\nserver_tokensoff;\naccess_log/var/log/nginx/phpipam.access.log;\nerror_log/var/log/nginx/phpipam.error.log;\nroot/var/www/phpipam;\n\nlocation/{\ntry_files$uri$uri//index.php;\nindexindex.php;\n}\n\nlocation/api/{\ntry_files$uri$uri//api/index.php;\n}\n\nlocation~\\.php${\nfastcgi_passunix:/run/php-fpm/www.sock;\nfastcgi_indexindex.php;\ntry_files$uri$uri/index.php=404;\nfastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;\nincludefastcgi_params;\n}\n\nerror_page404/404.html;\nlocation=/40x.html{\n}\n\nerror_page500502503504/50x.html;\nlocation=/50x.html{\n}\n}

选项2:使用443端口提供服务,需要提前准备证书,支持通过域名访问

server{\nlisten80;\nserver_namemgmt-ipam.corp.local;\nserver_tokensoff;\nlocation/{\nreturn301https://$server_name$request_uri;\n}\n}\n\nserver{\nlisten443sslhttp2;\nlisten[::]:443sslhttp2;\nserver_namemgmt-ipam.corp.local;\naccess_log/var/log/nginx/phpipam.access.log;\nerror_log/var/log/nginx/phpipam.error.log;\nroot/var/www/phpipam;\n\nssl_certificate"/usr/local/certs/mgmt-ipam-chain.pem";\nssl_certificate_key"/usr/local/certs/mgmt-ipam-key.pem";\nssl_session_cacheshared:SSL:1m;\nssl_session_timeout10m;\nssl_ciphersPROFILE=SYSTEM;\nssl_prefer_server_cipherson;\n\nlocation/{\ntry_files$uri$uri//index.php;\nindexindex.php;\n}\n\nlocation/api/{\ntry_files$uri$uri//api/index.php;\n}\n\nlocation~\\.php${\nfastcgi_passunix:/run/php-fpm/www.sock;\nfastcgi_indexindex.php;\ntry_files$uri$uri/index.php=404;\nfastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;\nincludefastcgi_params;\n}\n\nerror_page404/404.html;\nlocation=/40x.html{\n}\n\nerror_page500502503504/50x.html;\nlocation=/50x.html{\n}\n}\n

最后需要删除/etc/nginx/nginx.conf中的以下部分,其与phpipam.conf有冲突;

注意:此部分内容是安装软件包时自动添加的。

server{\nlisten80;\nlisten[::]:80;\nserver_name_;\nroot/usr/share/nginx/html;\n\n#Loadconfigurationfilesforthedefaultserverblock.\ninclude/etc/nginx/default.d/*.conf;\n\nerror_page404/404.html;\nlocation=/404.html{\n}\n\nerror_page500502503504/50x.html;\nlocation=/50x.html{\n}\n}\n

设置Nginx自启动和启动服务。

sudosystemctlenable--nownginx

打开防火墙的80和443端口,允许外部访问。

sudofirewall-cmd--permanent--add-port=80/tcp\nsudofirewall-cmd--permanent--add-port=443/tcp\nsudofirewall-cmd--reload部署phpIPAM

phpIPAM的源代码文件,可以通过Git克隆的方式获取,并支持后期升级。

使用git克隆phpIPAM到/var/www下;

sudogitclonehttps://github.com/phpipam/phpipam.git/var/www/phpipam/\ncd/var/www/phpipam\nsudogitcheckout1.5\nsudocpconfig.dist.phpconfig.php

更改文件权限,以支持访问和xls/csv导入;

cd/var/www\nsudochownnginx:nginx-R/var/www/phpipam/\nsudochcon-R-thttpd_sys_content_t/var/www/phpipam/\n\ncd/var/www/phpipam/\nfind.-typef-execchmod0644{}\\;\nfind.-typed-execchmod0755{}\\;\n\nsudochcon-thttpd_sys_rw_content_tapp/admin/import-export/upload/-R\nsudochcon-thttpd_sys_rw_content_tapp/subnets/import-subnet/upload/-R\nsudochcon-thttpd_sys_rw_content_tcss/images/logo/-R

修改config.php配置文件,添加数据库连接信息。

sudovi/var/www/phpipam/config.php\n

修改以下数据库连接内容:

/**\n*databaseconnectiondetails\n******************************/\n$db['host']='localhost';\n$db['user']='phpipam';\n$db['pass']='StrongPass123!';\n$db['name']='phpipam';\n$db['port']=3306;

重启Nginx服务

sudosystemctlrestartnginx使用Web初始化PHPIPAM系统

浏览器访问http://<ipaddress>,选择“Newphpipaminstallation”,进行初始化。

phpnow卸载

选择数据库初始化方式,本示例选择“Automaticdatabaseinstallation”,自动化配置数据库。

输入数据库的root账户和密码,点击“Installphpipamdatabase”。

配置默认本地管理员密码,用户名为“Admin”,配置网站名称和站点访问URL(例如:使用域名访问)。

部署完成后,使用Admin用户登录系统。

点击右上角的“用户”,可以配置页面语言为简体中文。

phpIPAM支持多种认证方式,AD、LDAP、SAML2(单点登录),根据实际环境选择,这次以集成AD认证为示例。

输入AD的连接信息后,点击“添加”。

进入左侧的“服务器管理”->“用户”,添加AD认证用户到PHPIPAM中,点击右侧的“搜索”按钮,搜索AD中的用户,并添加,选择用户的角色“管理员”或“普通用户”,最后,点击“添加按钮”。

最终,我们成功使用AD用户登录到PHPIPAM系统。

完成

至此,我们完成了PHPIPAM的平台搭建,具体使用方法,请参考官网指导文档。

版权声明:本网站为非赢利网站,作品与素材版权均归作者所有,如内容侵权与违规请发邮件联系,我们将在三个工作日内予以改正,请发送到chengfengseo#gmail.com(#换成@)。

本文链接:https://www.jr-cnc.cn/post/87f0fb26fdc8d4fc1e28bfad.html

TAG:

相关推荐