系统版本:CentOS-6.5-x86_64一、系统环境1、主机名1234[root@nagios ~]# hostname nagios.ewin.com[root@nagios ~]# vi /etc/sysconfig/network
NETWORKING=yesHOSTNAME=nagios.ewin.com2、yum源(1)使用本地源挂载光盘或ISO文件并配置源:12345678910[root@nagios ~]# mkdir /media/cdrom
[root@nagios ~]# mount /dev/cdrom /media/cdrom/[root@nagios ~]# cd /etc/yum.repos.d[root@nagios yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@nagios yum.repos.d]# vi CentOS-Base.repo[base]name=Basebaseurl=file:///media/cdrom/gpgcheck=0enabled=1
(2)添加163的源1[root@nagios yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo(3)更新列表1
2[root@nagios yum.repos.d]# yum clean all[root@nagios yum.repos.d]# yum list(4)解除锁定状态使用yum安装时可能会出现锁定状态,报错如下:
1Another app is currently holding the yum lock; waiting for it to exit…解决方法:1[root@nagios ~]# rm -f /var/run/yum.pid
3、X桌面环境查看是否安装了桌面环境的组件,没有则进行组安装:12[root@nagios ~]# yum grouplist | more[root@nagios ~]# yum groupinstall -y “Desktop” “Desktop Platform” “Desktop Platform Development” “Fonts” ”General Purpose Desktop” “Graphical Administration Tools” “Graphics Creation Tools” ”Input Methods” ”X Window System” ”Chinese Support [zh]” ”Internet Browser”
修改启动级别为5后重启服务器:123[root@nagios ~]# vi /etc/inittabid:5:initdefault:[root@nagios ~]# reboot4、网卡配置查看网络配置:
1234567891011121314151617[root@nagios ~]# ifconfig -aeth0 Link encap:Ethernet HWaddr 00:15:5D:01:2C:00
inet addr:10.188.1.103 Bcast:10.188.1.255 Mask:255.255.255.0 inet6 addr: fe80::215:5dff:fe01:2c00/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:20570650 errors:0 dropped:0 overruns:0 frame:0
TX packets:23909757 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:1997534214 (1.8 GiB) TX bytes:1952904919 (1.8 GiB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1691114 errors:0 dropped:0 overruns:0 frame:0 TX packets:1691114 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0 RX bytes:96615865 (92.1 MiB) TX bytes:96615865 (92.1 MiB)
手动设置网卡:1234567891011[root@nagios ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0 #接口名称
TYPE=Ethernet #接口类型:以太网ONBOOT=yes #开机启动BOOTPROTO=static #静态IPHWADDR=00:15:5D:01:2C:00 #MAC地址
IPADDR=10.188.1.103 #IP地址PREFIX=24 #子网掩码位数,或使用NETMASK=255.255.255.0GATEWAY=10.188.1.1 #网关地址
DNS1=10.188.1.2 #DNS服务器地址,我这是内网的DNSDNS2=202.101.224.68 #公网DNS服务器地址重启网卡:1[root@nagios ~]# ifdown eth0 && ifup eth0
5、vnc远程桌面安装及启动进程1(端口号是5900+1):123[root@nagios ~]# yum install -y tigervnc-server[root@nagios ~]# vncserver :1
#输入密码123456配置启动脚本,使用Gnome会话模式:12345[root@nagios ~]# vi /root/.vnc/xstartupunset SESSION_MANAGERexec /etc/X11/xinit/xinitrc
#twm&gnome-session重启vnc进程:12[root@nagios ~]# vncserver -kill :1[root@nagios ~]# vncserver :1设置开机自动启动:
1234[root@nagios ~]# vi /etc/sysconfig/vncserversVNCSERVERS=”1:root”VNCSERVERARGS[1]=”-geometry 800×600 -alwaysshared “
[root@nagios ~]# chkconfig vncserver on6、selinux安全项123[root@nagios ~]# vi /etc/selinux/configSELINUX=disabled
[root@nagios ~]# setenforce 07、ntpupdate时间同步12345[root@nagios ~]# crontab -e0 * * * * /usr/sbin/ntpdate 65.55.56.206 #1小时同步一次
[root@nagios ~]# service crond restart[root@nagios ~]# ntpdate 65.55.56.20618 Nov 10:07:49 ntpdate[8567]: step time server 65.55.56.206 offset -0.743765 sec
8、FTP文件传输1234567891011[root@nagios ~]# yum install -y vsftpd[root@nagios ~]# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO #禁止匿名访问userlist_deny=NO #(手动添加)使用FTP用户表[root@nagios ~]# useradd ywzhou[root@nagios ~]# passwd ywzhou
#输入密码123456[root@nagios ~]# vi /etc/vsftpd/user_listywzhou[root@nagios ~]# /etc/init.d/vsftpd start[root@nagios ~]# chkconfig vsftpd on
9、防火墙1234[root@nagios ~]# iptables -I INPUT -p tcp –dport 80 -j ACCEPT[root@nagios ~]# iptables -I INPUT -p tcp –dport 21 -j ACCEPT
[root@nagios ~]# iptables -I INPUT -p tcp –dport 5901 -j ACCEPT[root@nagios ~]# service iptables save
二、LAMP环境1、安装Apache1234567[root@nagios ~]# yum install -y httpd[root@nagios ~]# vi /etc/httpd/conf/httpd.conf
DirectoryIndex index.php index.htmlAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
[root@nagios ~]# service httpd start[root@nagios ~]# chkconfig httpd on2、安装PHP1[root@nagios ~]# yum -y install php php-devel php-snmp php-gd php-mysql
访问测试:12[root@nagios ~]# vi /var/www/html/index.phphttp://localhost结论:会显示php的相关信息表示php+apache整合成功
3、安装Mysql1234[root@nagios ~]# yum install mysql mysql-server mysql-devel[root@nagios ~]# service mysqld start
[root@nagios ~]# chkconfig mysqld on[root@nagios ~]# mysqladmin -u root password 123456当主机断电重启后zabbix无法连接mysql,报错如下:
1Another MySQL daemon already running with the same unix socket要先删除mysql.sock文件才能启动mysqld,因此在执行下面的命令开机重启mysql:
1[root@nagios ~]# echo “rm -f /var/lib/mysql/mysql.sock && service mysqld restart” >> /etc/rc.local三、编译环境
1、安装gcc1[root@nagios ~]# yum install gcc2、安装glibc1[root@nagios ~]# yum install glibc glibc-common3、安装gd
1[root@nagios ~]# yum install gd gd-devel4、安装pcap1[root@nagios ~]# yum install libtool libpcap libpcap-devel gdbm gdbm-devel zlib zlib-devel