系统版本:CentOS-6.5-x86_64
一、系统环境
1、主机名
[root@zabbix ~]# hostname zabbix.ewin.com [root@zabbix ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=zabbix.ewin.com
2、yum源
(1)使用本地源
挂载光盘或ISO文件并配置源:
[root@zabbix ~]# mkdir /media/cdrom [root@zabbix ~]# mount /dev/cdrom /media/cdrom/ [root@zabbix ~]# cd /etc/yum.repos.d [root@zabbix yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak [root@zabbix yum.repos.d]# vi CentOS-Base.repo [base] name=Base baseurl=file:///media/cdrom/ gpgcheck=0 enabled=1
(2)添加163的源
[root@zabbix yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
(3)更新列表
[root@zabbix yum.repos.d]# yum clean all [root@zabbix yum.repos.d]# yum list
(4)解除锁定状态
使用yum安装时可能会出现锁定状态,报错如下:
Another app is currently holding the yum lock; waiting for it to exit...
解决方法:
[root@zabbix ~]# rm -f /var/run/yum.pid
3、X桌面环境
查看是否安装了桌面环境的组件,没有则进行组安装:
[root@zabbix ~]# yum grouplist | more [root@zabbix ~]# 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后重启服务器:
[root@zabbix ~]# vi /etc/inittab id:5:initdefault: [root@zabbix ~]# reboot
4、网卡配置
查看网络配置:
[root@zabbix ~]# ifconfig -a eth0 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)
手动设置网卡:
[root@zabbix ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 #接口名称 TYPE=Ethernet #接口类型:以太网 ONBOOT=yes #开机启动 BOOTPROTO=static #静态IP HWADDR=00:15:5D:01:2C:00 #MAC地址 IPADDR=10.188.1.103 #IP地址 PREFIX=24 #子网掩码位数,或使用NETMASK=255.255.255.0 GATEWAY=10.188.1.1 #网关地址 DNS1=10.188.1.2 #DNS服务器地址,我这是内网的DNS DNS2=202.101.224.68 #公网DNS服务器地址
重启网卡:
[root@zabbix ~]# ifdown eth0 && ifup eth0
5、vnc远程桌面
安装及启动进程1(端口号是5900+1):
[root@zabbix ~]# yum install -y tigervnc-server [root@zabbix ~]# vncserver :1 #输入密码123456
配置启动脚本,使用Gnome会话模式:
[root@zabbix ~]# vi /root/.vnc/xstartup unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc #twm& gnome-session
重启vnc进程:
[root@zabbix ~]# vncserver -kill :1 [root@zabbix ~]# vncserver :1
设置开机自动启动:
[root@zabbix ~]# vi /etc/sysconfig/vncservers VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared " [root@zabbix ~]# chkconfig vncserver on
6、selinux安全项
[root@zabbix ~]# vi /etc/selinux/config SELINUX=disabled [root@zabbix ~]# setenforce 0
7、ntpupdate时间同步
[root@zabbix ~]# crontab -e 0 * * * * /usr/sbin/ntpdate 65.55.56.206 #1小时同步一次 [root@zabbix ~]# service crond restart [root@zabbix ~]# ntpdate 65.55.56.206 18 Nov 10:07:49 ntpdate[8567]: step time server 65.55.56.206 offset -0.743765 sec
8、FTP文件传输
[root@zabbix ~]# yum install -y vsftpd [root@zabbix ~]# vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO #禁止匿名访问 userlist_deny=NO #(手动添加)使用FTP用户表 [root@zabbix ~]# useradd ywzhou [root@zabbix ~]# passwd ywzhou #输入密码123456 [root@zabbix ~]# vi /etc/vsftpd/user_list ywzhou [root@zabbix ~]# /etc/init.d/vsftpd start [root@zabbix ~]# chkconfig vsftpd on
9、防火墙
[root@zabbix ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT [root@zabbix ~]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT [root@zabbix ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT [root@zabbix ~]# service iptables save
二、LAMP环境
1、安装Apache
[root@zabbix ~]# yum install -y httpd [root@zabbix ~]# vi /etc/httpd/conf/httpd.conf DirectoryIndex index.php index.html AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps [root@zabbix ~]# service httpd start [root@zabbix ~]# chkconfig httpd on
2、安装PHP
[root@zabbix ~]# yum -y install php php-gd php-xml php-bcmath php-mbstring php-mysql
访问测试:
[root@zabbix ~]# vi /var/www/html/index.php
http://localhost
结论:会显示php的相关信息表示php+apache整合成功
3、安装Mysql
[root@zabbix ~]# yum install mysql mysql-server mysql-devel [root@zabbix ~]# service mysqld start [root@zabbix ~]# chkconfig mysqld on [root@zabbix ~]# mysqladmin -u root password '123456'
当主机断电重启后zabbix无法连接mysql,报错如下:
Another MySQL daemon already running with the same unix socket
要先删除mysql.sock文件才能启动mysqld,因此在执行下面的命令开机重启mysql:
[root@zabbix ~]# echo "rm -f /var/lib/mysql/mysql.sock && service mysqld restart" >> /etc/rc.local
结论: 本节安装环境的部署适用于大部分的应用环境。