因之前 IP 管理都是用 EXCEL 表單來做記錄,那有時候如果忘了記錄就比較麻煩不知道是否有記錄到新的 IP ,我們可以利用這一套 IP 管理服務來記錄目前的狀況
yum install nginx -y
啟動服務
systemctl start nginx ; systemctl enable nginx
vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list - created 2019-08-10 02:29 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum install MariaDB-server MariaDB-client -y
systemctl enable mariadb ; systemctl start mariadb
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n]
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
mysql -u root -p
GRANT ALL PRIVILEGES ON phpipamdb.* TO 'phpipamuser'@'localhost' IDENTIFIED BY '設定使用者密碼' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
yum install -y epel-release yum-utils
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php73
yum install -y php php-cli php-gd php-common php-ldap php-pdo php-pear php-snmp php-xml php-mysql php-mbstring php-gmp php-fpm php-mcrypt git
vim /etc/php.ini
設定檔修改前
;cgi.fix_pathinfo=1
修改後
cgi.fix_pathinfo=0
修改時區
[Date]
修改前
;date.timezone =
修改後
date.timezone = Asia/Taipei
存檔
:wq
vim /etc/php-fpm.d/www.conf
由誰使用此服務
; RPM: apache user chosen to provide access to the same directories as httpd
;user = apache
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = apache
listen = 127.0.0.1:9000
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
修改好存檔
:wq
systemctl restart php-fpm ; systemctl enable php-fpm
cd /var/www/html/
下載官方在 github
git clone https://github.com/phpipam/phpipam.git
進到 phpipam 目錄
cd phpipam/
確認安裝的版本
git submodule update --init --recursive
chown nginx:nginx -R /var/www/html/phpipam/
cp config.dist.php config.php
vim config.php
設定資料庫的帳密訊息
/**
* database connection details
******************************/
$db['host'] = 'localhost';
$db['user'] = 'phpipam';
$db['pass'] = 'phpipamadmin';
$db['name'] = 'phpipamdb';
$db['port'] = 3306;
if(!defined('BASE'))
define('BASE', "/");
vim phpipam.conf
server {
# 這個主機的 Port
listen 80;
# 這個主機的名稱
server_name 服務主機位置;
root /var/www/html/phpipam;
#
access_log /var/log/nginx/phpipam_access.log;
error_log /var/log/nginx/phpipam_error.log;
#
client_max_body_size 1G;
fastcgi_buffers 64 4K;
#
# html 檔
# phpipam
location / {
try_files $uri $uri/ /index.php;
index index.php;
}
# phpipam - api
location /api/ {
try_files $uri $uri/ /api/index.php;
}
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# php 檔
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
try_files $uri = 404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#
location ~* \.(?:ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires 30d;
log_not_found off;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
# location ~ /\.ht {
# deny all;
# }
# 發生 404 指定導向哪個網頁
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
# location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
}
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl restart nginx
mysql -u root -p
CREATE DATABASE IF NOT EXISTS phpipamdb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON phpipamdb.* TO 'phpipamuser'@'localhost' IDENTIFIED BY '設定使用者密碼' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
cd /var/www/html/phpipam/db
mysql -u root -p phpipamdb < SCHEMA.sql
http://ip/
,預設帳號為 admin,預設密碼為 ipamadmin,即可開始登入 phpIPAM 系統,登入後系統會要求修改管理者的密碼,修改完之後再使用新的密碼登入就可以使用了