当前位置: > CentOS > CentOS教程 >

CentOS6.2系统基本软件环境配置教程

时间:2014-05-04 22:24来源:linux.it.net.cn 作者:it

一、安装CentOS6.2系统

1、选择Desktop进行安装

注:如果修改了主机名,则需要在/etc/hosts文件中增加设置的主机名

2、ssh安全设置(配置文件:/etc/ssh/sshd_config):

  1)更改默认22端口:去掉 Port的注释,改成如:22123

  2)禁止root账号登录:去掉PermitRootLogin yes注释,改成:PermitRootLogin no

  3)新增SSH登录用户,登录成功后再su到root:


		
  1. # useradd xiaoma
  2. # passwd xiaoma

    然后修改ssh配置文件,最后加入:AllowUsers xiaoma

  4)重启SSH服务:service sshd restart

  5)更改防火墙配置,允许22123端口,加入:-A INPUT -m state –state NEW -m tcp -p tcp –dport 22123 -j ACCEPT,并重启防火墙生效:service iptables restart

二、软件环境配置

1、安装编译环境:


		
  1. # yum install gcc gcc-c++

注:代理上网,命令行:export http_proxy=http://ip:port

2、安装一些必备的库


		
  1. # yum install ncurses-devel zlib-devel libjpeg* libpng* freetype*

注:ncurses-devel – 编译安装mysql5.5时需要    zlib-devel – 编译安装httpd需要    libjpeg*、libpng*、freetype* – 编译安装php需要

3、安装clamAV杀毒软件


		
  1. # tar xzf clamav-0.97.4.tar.gz
  2. # cd clamav-0.97.4
  3. # ./configure --prefix=/usr/local/clamav --disable-clamav
  4. # make
  5. # make install
  6.  
  7. # groupadd clamav
  8. # useradd -g clamav clamav
  9. # chown -R clamav.clamav /usr/local/clamav

   操作示例:    1)更新病毒库:bin/freshclam(需要修改etc/freshclam.conf文件把Example行注释掉)    2)扫描指定的目录:bin/clamscan –bell -i -r /usr/local

4、安装JDK


		
  1. # chmod +x jdk-6u33-linux-i586.bin
  2. # ./jdk-6u33-linux-i586.bin
  3. # mv jdk1.6.0_33/ /usr/local

   设置JDK环境变量,/etc/profile文件中最后加入如下配置:


		
  1. JAVA_HOME=/usr/local/jdk1.6.0_33
  2. export JAVA_HOME
  3. export PATH=/usr/local/mysql5/bin:$JAVA_HOME/bin:$PATH

   然后更新环境变量使之生效:


		
  1. # source /etc/profile

   查看安装的java版本:


		
  1. # java -version

5、安装Mysql5.5(mysql5.5需要cmake编译,需要先安装cmake)


		
  1. # tar xzf cmake-2.8.7.tar.gz
  2. # cd cmake-2.8.7
  3. # ./configure
  4. # make && make install
  5.  
  6. # mkdir -p /usr/local/mysql5
  7. # groupadd mysql
  8. # useradd -g mysql mysql
  9. # chown mysql.mysql -R /usr/local/mysql5
  10.  
  11. # tar xzf mysql-5.5.19.tar.gz
  12. # cd mysql-5.5.19/
  13. # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5 -DMYSQL_UNIX_ADDR=/usr/local/mysql5/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql5/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
  14. # make
  15. # make install

   配置Mysql,进行如下操作:


		
  1. # cp support-files/my-medium.cnf /etc/my.cnf
  2. # chmod 755 scripts/mysql_install_db
  3. # scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5 --datadir=/usr/local/mysql5/data
  4.  
  5. # cp support-files/mysql.server /etc/init.d/mysql
  6. # chmod 755 /etc/init.d/mysql
  7. # chkconfig mysql on

   启动mysql并设置root账号密码:


		
  1. # /etc/init.d/mysql start 或 service mysql start
  2. # /usr/local/mysql5/bin/mysqladmin -uroot password 'root'

   加入环境变量,在/etc/profile文件中最后加入:


		
  1. export PATH=/usr/local/mysql5/bin:$PATH

   修改默认的mysql最大连接数(默认只有151),打开/etc/my.cnf文件,在[mysqld]的下面加入:max_connections=1000,然后重启mysql即可生效,查看最大连接数:


		
  1. mysql>show VARIABLESLIKE'%conn%';

6、安装httpd


		
  1. # tar xzf httpd-2.2.21.tar.gz
  2. # cd httpd-2.2.21/
  3. # cd srclib/apr
  4. # ./configure --prefix=/usr/local/apr
  5. # make
  6. # make install
  7.  
  8. # cd ../apr-util
  9. # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  10. # make
  11. # make install
  12.  
  13. # cd ../..
  14. # ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-dav --enable-proxy --enable-proxy-ajp
  15. # make
  16. # make install

   启动httpd并访问http://ip进行测试(注意iptables需要打开80端口):


		
  1. # /usr/local/apache2/bin/apachectl start

   如果需要禁止对某个目录的访问,可以在该目录下新建.htaccess文件,并输入如下内容:


		
  1. order allow,deny
  2. deny from all

7、安装php


		
  1. # tar xzf libxml2-2.7.5.tar.gz
  2. # cd libxml2-2.7.5
  3. # ./configure --prefix=/usr/local/libxml2
  4. # make
  5. # make install
  6.  
  7. # cd ..
  8. # rpm -qa php
  9. # rpm -e --nodeps --allmatches php-5.1.6-27.el5
  10. # tar xzf php-5.3.1.tar.gz
  11. # cd php-5.3.1
  12. # ./configure --prefix=/usr/local/php5 --with-libxml-dir=/usr/local/libxml2/ --with-mysql=/usr/local/mysql5/ --with-apxs2=/usr/local/apache2/bin/apxs  --with-mbstring --enable-mbstring=all --with-gd
  13. # make
  14. # make install
  15. # cp php.ini-production /usr/local/php5/lib/php.ini

   修改httpd.conf文件:

   1)在AddType application/x-gzip .gz .tgz之后加一行:AddType application/x-httpd-php  .php    2)在DirectoryIndex index.html后加入index.php

   重启httpd后即可使php生效!

8、安装Tomcat7


		
  1. # unzip -q apache-tomcat-7.0.23.zip
  2. # mv apache-tomcat-7.0.23 tomcat-7

   配置tomcat的虚拟主机,打开conf/server.xml配置文件,加入如下段(多个则加入多个如下段即可):


		
  1. <Hostname="www.mzone.cc"appBase="webapps"
  2. unpackWARs="true"autoDeploy="true">
  3. <Alias>chinapis.com</Alias>
  4. <Contextpath=""docBase="/webapps/www.mzone.cc"/>
  5. </Host>

   配置完tomcat后,还需要配置apache的虚拟主机文件(conf/extra/httpd-vhosts.conf):


		
  1. <VirtualHost *:80>
  2.    DocumentRoot "/kington/webapps/chinapis"
  3.    ServerName www.mzone.cc
  4.    ServerAlias mzone.cc
  5.  
  6.    ErrorLog "| /usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/mzone.cc_%Y-%m-%d_error_log 86400 480"
  7.    CustomLog "| /usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/mzone.cc_%Y-%m-%d_access_log 86400 480" common
  8.  
  9.    ProxyPass /images/ !
  10.    ProxyPass /styles/ !
  11.  
  12.    ProxyPreserveHost On
  13.    ProxyPass / ajp://localhost:8009/
  14.    ProxyPassReverse / ajp://localhost:8009/
  15. </VirtualHost>

   上述配置中的说明如下:

   1)ErrorLog和CustomLog配置了日志文件的轮询时间(86400表示秒是一天,480是时区的偏移)

三、常见问题

1、编译安装php时遇到:configure: error: libpng.(a|so) not found,首先安装各个依赖组件(libjpeg、libpng、freetype),然后做如下处理:


		
  1. # ln -s /usr/lib64/libjpeg.so /usr/lib/
  2. # ln -s /usr/lib64/libpng.so /usr/lib/

2、解压bin格式的jdk时候报错:/lib/ld-linux.so.2: bad ELF interpreter,需要安装一些缺少的文件:


		
  1. # yum install ld-linux.so.2
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容