1. 申請憑證檔案
- certificate.crt 伺服器憑證
- private.key 憑證私鑰
- ca_bundle.crt 中繼憑證
2. 下載的憑證檔放至主機資料夾中,CentOS 7 預設路徑為/etc/pki/tls/certs,可自己訂路徑
1. 申請憑證檔案
- certificate.crt 伺服器憑證
- private.key 憑證私鑰
- ca_bundle.crt 中繼憑證
2. 下載的憑證檔放至主機資料夾中,CentOS 7 預設路徑為/etc/pki/tls/certs,可自己訂路徑
下載Centos 網址如下
http://isoredirect.centos.org/centos/7/isos/x86_64/
可下載CentOS-7-x86_64-Minimal-2003.iso縮小版大約1GB
安裝VIM&Ifconfig等工具
yum -y update
yum -y install vim
yum -y install net-tools
yum -y install wget
Yum 安裝 Htop:
首先啟用 EPEL Repository:
# yum -y install epel-release
# yum -y update
首用 EPEL Repository 後, 可以用 yum 直接安裝 Htop:
# yum -y install htop
安裝好 Htop 後, 啟動只需執行 “htop” 指令:
# htop
CentOS 7 關閉防火牆及 SELinux
關閉 SELinux:
開啟檔案 /etc/selinux/config:
# vim /etc/selinux/config
找到以下一行:
SELINUX=enforce 改成: SELINUX=disabled
另外將 “SELINUXTYPE=targeted” 加上註釋, 改成這樣:
# SELINUXTYPE=targeted
儲存後離開編輯器, 需要重新開機設定才會生效。
要檢查 SELinux 的狀態, 執行 sestatus 指令便可以看到:
# sestatus
關閉 Firewalld 防火牆:
關閉 Firewalld 防火牆指令:# systemctl stop firewalld.service
設定下次開機不啟動 Firewalld 防火牆
# systemctl disable firewalld.service
在CentOS 6和CentOS 7或CentOS 8上安裝PHP 5.4、5.5、5.6或7.3、7.4版本
1.wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm
安裝Apache及支援https的模組!
1 | [root@localhost ~]$ sudo yum -y install httpd mod_ssl openssl |
啟動Apache及設定開機啟動
1 2 | [root@localhost ~]$ sudo systemctl start httpd [root@localhost ~]$ sudo systemctl enable httpd |
查詢Apache執行權限
1 | [root@localhost ~]$ sudo vim /etc/httpd/conf/httpd.conf |
尋找關鍵字『User 』
(尾端加上一個空白鍵)
1 | /User |
1 2 3 4 5 6 7 8 9 10 | # # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User apache Group apache |
如此一來,便可確定Apache執行者是apache,想要讓Apache擁有權限的檔案或目錄,就要變更擁有者為apache!
設定或修改Apache目錄
1 | [root@localhost ~]$ sudo vim /etc/httpd/conf/httpd.conf |
尋找『DocumentRoot 』
1 | /DocumentRoot |
1 2 3 4 5 6 | # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/var/www/html" |
為了讓Apache可以支援.htaccess,請加入AllowOverride All
搜尋『<directory 』,可能會找到好幾個,要修改的是後方雙引號內容為Apache預設目錄
1 | /<directory\ |
1 2 3 | <directory "/var/www/html"> AllowOverride All </Directory> |
一般而言,Apache Http Server預設使用80 port,如要修改可搜尋『Listen 80』
1 2 3 4 5 6 7 8 9 10 | # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 Listen 80 |
有修改設定的話,記得存檔離開!
1 | :wq |
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum -y install mysql-community-server
安裝成功後重啟mysql服務。
# service mysqld restart
初次安裝mysql,root賬戶沒有密碼。
查看一下狀態
1 | [root@Localhost ~]$ sudo systemctl status mysqld.service |
初次安裝mysql,root賬戶沒有密碼。
[root@localhost]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.48 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| |
+--------------------+
3 rows in set (0.01 sec) mysql>
設定密碼
mysql> set password for 'root'@'localhost' =password('mypassword'); Query OK, 0 rows affected (0.00 sec) mysql>
不需要重啟資料庫即可生效。
設定開機自動啟動MySQL服務
1 | [root@localhost ~]$ sudo systemctl enable mysqld |
設定防火牆允許外網存取MySQL服務
(如果系統架構是程式和資料庫都在同一台伺服器,就不需要做這個設定!)
1 | [root@localhost ~]$ sudo firewall-cmd --zone=public --add-service=mysql |
解壓縮
1 | [root@localhost ~]$ sudo tar -xvf phpMyAdmin-4.0.10.20-all-languages.tar.gz |
將phpMyAdmin的根目錄更名,並且移動到你想放置的目錄下
(本範例欲將根目錄更名為phpmyadmin,並且放置到/usr/share/之下)
1 | [root@localhost ~]$ sudo mv phpMyAdmin-4.0.10.20-all-languages /var/www/html/phpmyadmin |
(parted) set 4 lvm on 將第4磁區設定為 LVM
(parted) quit 跳出
# pvcreate /dev/sda4 設定第4磁區 # vgdisplay # vgextend centos /dev/sda4
# lvdisplay 秀磁區資訊
# lvextend /dev/centos/root /dev/sda4 合併第4磁區
lvdisplay 再查詢磁區將有變化放大
# df -h
查詢時可能會發現硬碟空間顯示依然是舊的,必須進行重新掃描
xfs 檔案系統:
# xfs_growfs /dev/centos/root
ext4 檔案系統:
# resize2fs /dev/centos/root
# df -h