1.設定網路卡

vi /etc/sysconfig/network-scripts/ifcfg-enoxxxxxxx

ONBOOT=yes

TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

 

一、啟動 IPv6

檢視IPv6模組是否已經掛進系統,如果預設沒啟動IPv6,則修改 /etc/modprobe.conf ,加入:

alias net-pf-10 ipv6

如果有這兩行,把他移除
alias ipv6 off
alias net-pf-10 off

請重新開機。

二、讓網卡介面中的 IPv6 設定生效

步驟一已經能正常使用IPv6,但如果網卡要設定 IPv6 屬性,則要修改 /etc/sysconfig/network,加入這行:

NETWORKING_IPV6=yes

修改網卡介面,vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPV6ADDR=2001:288:5400:1::12/64
IPV6_DEFAULTGW=2001:288:5400::ff
IPV6INIT=yes

重啟網卡 /etc/init.d/network restart 或 service network restart

 

 

設定網路

2.設定服務更新

#yum -y install cronie

#yum -y install yum-cron

#vi /etc/yum/yum-cron.conf

  apply_updates=no-->yes

   update_messages = yesdownload_updates = yesapply_updates = yes

#systemctl start crond

#systemctl start yum-cron

 

3.修改時區

# rm /etc/locatime

# ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime

4.網路校時

yum install chrony
vi /etc/chrony.conf

# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
server tick.stdtime.gov.tw iburst
server watch.stdtime.gov.tw iburst

systemctl start chronyd
systemctl enable chronyd

chronyc -a
chronyc> tracking (檢視時間差)
chronyc> sources (查看 NTP server 狀態)
chronyc> makestep (手動立即校時)
chronyc> exit

5.Routing表

#ip route

#ip route show

#route -n

6.列出所有開啟的port

#vi /etc/services

#netstat

#firewall-cmd --list-ports

# firewall-cmd --list-all

(firewall-cmd :頭城國小 http://blog.ilc.edu.tw/blog/blog/25793/post/78483/512887 )

CentOS 7 防火牆設定

#firewall-cmd --list-all
查看一下防火牆現在開啟了哪些服務和端口:

暫時開起or關閉
# firewall-cmd --add-service=https
# firewall-cmd --remove-service=https

永久開起
# firewall-cmd --add-service=ftp --permanent

查看防火牆
# iptables -L

開啟port
# /sbin/iptables -I INPUT -p tcp --dport 443 -j ACCEPT
# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT  

關閉port
# /sbin/iptables -I INPUT -p tcp --dport 80 -j REJECT

 

7.更改port 

# vi /etc/httpd/conf/httpd.conf

 改port

開port 

# firewall-cmd --permanent --add-port 8080/tcp

# firewall-cmd --reload

# firewall-cmd --complete-reload

 

8.改www資料夾

# vi /etc/httpd/conf/httpd.conf

改裡面兩個路徑

建立資料夾

增加一個index.php 

改完要 systemctl restart httpd

 

9.安裝apache、php、mariaDB

 

安裝 Apache 
yum install httpd

啟動 Web Server
service httpd start
Redirecting to /bin/systemctl start  httpd.service

systemctl start httpd

在防火牆開啟 http 服務
firewall-cmd --permanent --add-service=http
systemctl restart firewalld

設定開機時啟動 Web Server
systemctl enable httpd

安裝 PHP
yum install php php-mysql php-pdo php-gd php-mbstring

安裝 MariaDB
yum install mariadb-server mariadb

啟動 MariaDB
systemctl start mariadb

初始化資料庫設定
/usr/bin/mysql_secure_installation

設定開機時啟動 MariaDB
systemctl enable mariadb

10.安裝phpmyadmin

# yum install epel-release

# yum install phpmyadmin

# vi /etc/httpd/conf.d/phpMyAdmin.conf

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

. . . . .

<Directory /usr/share/phpMyAdmin/>

   AddDefaultCharset UTF-8

 

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

       #Require ip 127.0.0.1

       #Require ip ::1

       Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

     Deny from All

     Allow from 127.0.0.1

     Allow from ::1

   </IfModule>

</Directory>

 

<Directory /usr/share/phpMyAdmin/setup/>

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

       #Require ip 127.0.0.1

       #Require ip ::1

       Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

     Deny from All

     Allow from 127.0.0.1

     Allow from ::1

   </IfModule>

</Directory>

. . . . .

Finally, restart httpd to activate the change.

$ sudo systemctl restart httpd

 

11.正反解ip

#yum install bind bind-chroot bind-libs bind-utils

dig @168.95.1.1 yahoo.com.tw any

 

12.查詢路由

tracepath www.google.com

tracepath 相關

 

 

 

  # 這是打開讓自己網域可以方便連結,也就是該網域不設防

  iptables -A INPUT -p all -s ip_net/netmask -j ACCEPT

 

 

關閉firewalld,開啟iptables後的規則

firewalld    firewalld防火牆

網路管理

 

13.虛擬目錄

http://download.ithome.com.tw/article/index/id/2398

  五.apache添加虚拟目录

  由于apache默认工程目录在/var/www下,而该目录下的所有文件属主都是root用户,这样我们每次编写php文件都要获取到root权限进行

编辑,很是麻烦,因此可不可以我们自定义一个目录,让apache也识别出这个目录呢?

  当然是可以的,那就是本文接下来要讲的虚拟目录,建立虚拟目录的种种好处我这里就不多作介绍了,直接上方法。

  apache的服务配置文件在/etc/httpd/conf/httpd.conf中,编辑该文件前先做以下备份。

  cp httpd.conf httpd.conf.backup

  编辑httpd.conf文件,用Alisa来对你的自定义目录进行重命名,便于我们访问该目录下的文件。

  示例:

  Alias /bbs "/home/xxx/WorkSpace/www"
<Directory "/home/xxx/WorkSpace/www">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

我这里选择我的自定义路径是/home/xxx/WorkSpace/www,在该目录下新建一个index.html文件,目录对应的别名是/bbs,访问是

直接输入:http://localhost/bbs即可对真实目录/home/xxx/WorkSpace/www下的文件进行访问。

到这里,千万别以为完事大吉了,RedHat系引入了SELinux安全控制,管理着Linux中的众多网络服务,其中就包括对apache严格的访问控制。

到这一步,在浏览器中输入URL--http://localhost/bbs得到的应该是403错误代码。这时候,别着急,看一下/etc/httpd/logs目录下的

error_log文件内容,里面记录的apache的活动历史。

如果是AH00035错误代码,那么你有以下工作要做:

  1.检查自定义目录/home/xxx/WorkSpace/www的各级权限,对照着/var/www/html更改,分别修改目录权限和文件权限。

  2.若还是出现这个错误,那么八成就是SELinux搞的鬼了,首先,用 semanage fcontext -l | grep '/var/www' 获知默认 /var/www 目录的 SELinux 上下文,会得到一堆类似下面列举出来的信息:

       /var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:so

      从中可以看出apache只能访问包含httpdsyscontent_t标签的文件。若我们想访问自定义的网站目录,那么就需要给这个目录下的文件增加这个标签,分为两步实现:

      首先为自定义目录下的文件添加默认标签类型,semanage fcontext -a -t  httpd_sys_content_t '/home/xxx/WorkSpace/www(/.*)?',然后用新的标签类型标注已有文件:restorecon -R -v  /home/xxx/WorkSpace/www,之后apache就可以使用该目录了。

      2.到这一步出现AH00132错误代码,那么设置SELinux对目录下的文件可读,即可访问。

setsebool -P httpd_read_user_content 1

      到此,在输入http://localhost/bbs,就可访问到index.html文件的内容了。

arrow
arrow
    全站熱搜

    deliciousmenu 發表在 痞客邦 留言(0) 人氣()