系统版本:CentOS-6.5-x86_64
一、系统环境
1、yum源
(1)使用本地源
挂载光盘或ISO文件并配置源:
[[email protected] ~]# mkdir /media/cdrom [[email protected] ~]# mount /dev/cdrom /media/cdrom/ [[email protected] ~]# cd /etc/yum.repos.d [[email protected] yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak [[email protected] yum.repos.d]# vi CentOS-Base.repo [base] name=Base baseurl=file:///media/cdrom/ gpgcheck=0 enabled=1
(2)添加163的源
[[email protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
(3)更新列表
[[email protected] yum.repos.d]# yum clean all [[email protected] yum.repos.d]# yum list
(4)解除锁定状态
使用yum安装时可能会出现锁定状态,报错如下:
Another app is currently holding the yum lock; waiting for it to exit...
解决方法:
[[email protected] ~]# rm -f /var/run/yum.pid
2、X桌面环境
查看是否安装了桌面环境的组件,没有则进行组安装:
[[email protected] ~]# yum grouplist | more [[email protected] ~]# 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后重启服务器:
[[email protected] ~]# vi /etc/inittab id:5:initdefault: [[email protected] ~]# reboot
3、网卡配置
查看网络配置:
[[email protected] ~]# 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[email protected] ~]# 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服务器地址
重启网卡:
[[email protected] ~]# ifdown eth0 && ifup eth0
4、vnc远程桌面
安装及启动进程1(端口号是5900+1):
[[email protected] ~]# yum install -y tigervnc-server [[email protected] ~]# vncserver :1 #输入密码123456
配置启动脚本,使用Gnome会话模式:
[[email protected] ~]# vi /root/.vnc/xstartup unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc #twm& gnome-session
重启vnc进程:
[[email protected] ~]# vncserver -kill :1 [[email protected] ~]# vncserver :1
设置开机自动启动:
[[email protected] ~]# vi /etc/sysconfig/vncservers VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared " [[email protected] ~]# chkconfig vncserver on
5、selinux安全项
[[email protected] ~]# vi /etc/selinux/config SELINUX=disabled [[email protected] ~]# setenforce 0
6、ntpupdate时间同步
[[email protected] ~]# crontab -e 0 * * * * /usr/sbin/ntpdate 65.55.56.206 #1小时同步一次 [[email protected] ~]# service crond restart [[email protected] ~]# ntpdate 65.55.56.206 18 Nov 10:07:49 ntpdate[8567]: step time server 65.55.56.206 offset -0.743765 sec
7、FTP文件传输
[[email protected] ~]# yum install -y vsftpd [[email protected] ~]# vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO #禁止匿名访问 userlist_deny=NO #(手动添加)使用FTP用户表 [[email protected] ~]# useradd ywzhou [[email protected] ~]# passwd ywzhou #输入密码123456 [[email protected] ~]# vi /etc/vsftpd/user_list ywzhou [[email protected] ~]# /etc/init.d/vsftpd start [[email protected] ~]# chkconfig vsftpd on
8、防火墙
[[email protected] ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT [[email protected] ~]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT [[email protected] ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT [[email protected] ~]# service iptables save
二、LAMP环境
1、安装Apache
[[email protected] ~]# yum install -y httpd [[email protected] ~]# vi /etc/httpd/conf/httpd.conf DirectoryIndex index.php index.html AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps [[email protected] ~]# service httpd start [[email protected] ~]# chkconfig httpd on
2、安装PHP
[[email protected] ~]# yum -y install php php-gd php-xml php-bcmath php-mbstring php-mysql
后面三个包不在安装光盘中,需要用163源在线下载安装
3、安装Mysql
[[email protected] ~]# yum install mysql mysql-server mysql-devel [[email protected] ~]# service mysqld start [[email protected] ~]# chkconfig mysqld on [[email protected] ~]# mysqladmin -u root password ‘123456‘
当主机断电重启后zabbix无法连接mysql,要先删除mysql.sock文件才能启动mysqld,因此在执行下面的命令开机重启mysql:
[[email protected] ~]# echo "rm -f /var/lib/mysql/mysql.sock && service mysqld restart" >> /etc/rc.local
结论: 本节安装环境的部署适用于大部分的应用环境。
时间: 2024-12-14 11:16:23