CentOS LAMP网络配置要点如下:
配置网络接口
/etc/sysconfig/network-scripts/ifcfg-<网卡名>
(如 ifcfg-eth0
),设置 BOOTPROTO=static
(静态IP)或 dhcp
(动态IP),并配置 IPADDR
、NETMASK
、GATEWAY
、DNS1
等参数。sudo systemctl restart network
。ip addr show <网卡名>
或 ping
外部网络。配置防火墙
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
。配置SELinux(可选)
sudo setsebool -P httpd_can_network_connect 1
。验证网络连通性
ping
测试网络是否通畅,确保服务器可访问外部网络及数据库服务。注:部分步骤(如关闭SELinux、防火墙)可能因安全策略调整,生产环境需谨慎操作。