CentOS6.2 system installation and basic software environment configuration

Source: Internet
Author: User
During the past two days, the entire company's problematic servers successfully recorded the following processes for future reference and for your reference in CentOS.

1. install CentOS6.2

1. select Desktop for installation

Note: If you have modified the host name, you need to add the configured host name to the/etc/hosts file.

2. ssh security settings (Configuration File:/etc/ssh/sshd_config ):

1) change the default Port 22: remove the Port comment, for example, 22123.

2) disable root account logon: remove the PermitRootLogin yes annotation and change it to PermitRootLogin no.

3) add an SSH logon user and log on to the root user after successful logon:


Copy codeThe code is as follows:
# Useradd xiaoma
# Passwd xiaoma

Then modify the ssh configuration file and add: AllowUsers xiaoma.

4) restart the SSH service: service sshd restart

5) change the firewall configuration, allow port 22123, add:-a input-m state-state NEW-m tcp-p tcp-dport 22123-j ACCEPT, and restart the firewall to take effect: service iptables restart


2. software environment configuration

1. install the compiling environment:


Copy codeThe code is as follows:
# Yum install gcc-c ++

Note: the proxy accesses the internet. command line: export http_proxy = http: // ip: port

2. install necessary libraries


Copy codeThe code is as follows:
# Yum install ncurses-devel zlib-devel libjpeg * libpng * freetype *

Note: ncurses-devel-required to compile and install mysql5.5
Zlib-devel-required for compiling and installing httpd
Libjpeg *, libpng *, and freetype *-required for compiling and installing php

3. install clamAV antivirus software


Copy codeThe code is as follows:
# Tar xzf clamav-0.97.4.tar.gz
# Cd clamav-0.97.4
#./Configure -- prefix =/usr/local/clamav -- disable-clamav
# Make
# Make install

# Groupadd clamav
# Useradd-g clamav
# Chown-R clamav. clamav/usr/local/clamav

Operation example:
1) update the virus database: bin/freshclam (you need to modify the etc/freshclam. conf file to comment out the Example line)
2) scan the specified directory: bin/clamscan-bell-I-r/usr/local

4. install JDK


Copy codeThe code is as follows:
# Chmod + x jdk-6u33-linux-i586.bin
#./Jdk-6u33-linux-i586.bin
# Mv jdk1.6.0 _ 33 // usr/local

Set JDK environment variables. add the following configuration to the/etc/profile file:


Copy codeThe code is as follows:
JAVA_HOME =/usr/local/jdk1.6.0 _ 33
Export JAVA_HOME
Export PATH =/usr/local/mysql5/bin: $ JAVA_HOME/bin: $ PATH

Then update the environment variable to make it take effect:


Copy codeThe code is as follows:
# Source/etc/profile

View the installed java version:


Copy codeThe code is as follows:
# Java-version

5. install Mysql5.5 (mysql5.5 requires cmake compilation and cmake installation first)


Copy codeThe code is as follows:
# Tar xzf cmake-2.8.7.tar.gz
# Cd cmake-2.8.7
#./Configure
# Make & make install

# Mkdir-p/usr/local/mysql5
# Groupadd mysql
# Useradd-g mysql
# Chown mysql. mysql-R/usr/local/mysql5

# Tar xzf mysql-5.5.19.tar.gz
# Cd mysql-5.5.19/
# Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql5-DMYSQL_UNIX_ADDR =/usr/local/mysql5/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-rows = all-rows = 1-rows = 1-rows = 1-DWITH_READLINE = 1-rows = 1-DMYSQL_DATADIR =/usr /mysql5/data-DMYSQL_USER = mysql-DMYSQL_TCP_PORT = 3306.
# Make
# Make install

Configure Mysql as follows:


Copy codeThe code is as follows:
# Cp support-files/my-medium.cnf/etc/my. cnf
# Chmod 755 scripts/mysql_install_db
# Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql5 -- datadir =/usr/local/mysql5/data

# Cp support-files/mysql. server/etc/init. d/mysql
# Chmod 755/etc/init. d/mysql
# Chkconfig mysql on

Start mysql and set the root account password:


Copy codeThe code is as follows:
#/Etc/init. d/mysql start or service mysql start
#/Usr/local/mysql5/bin/mysqladmin-uroot password 'root'

Add Environment variables and add the following to the/etc/profile file:


Copy codeThe code is as follows:
Export PATH =/usr/local/mysql5/bin: $ PATH

Modify the default maximum number of connections of mysql (only 151 by default). open/etc/my. in the cnf file, add max_connections = 1000 under [mysqld], and then restart mysql to take effect. check the maximum number of connections:


Copy codeThe code is as follows:
Mysql> show variables like '% conn % ';

6. install httpd


Copy codeThe code is as follows:
# Tar xzf httpd-2.2.21.tar.gz
# Cd httpd-2.2.21/
# Cd srclib/apr
#./Configure -- prefix =/usr/local/apr
# Make
# Make install

# Cd ../apr-util
#./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr
# Make
# Make install

# Cd ../..
#. /Configure -- prefix =/usr/local/apache2 -- enable-so -- enable-MoD-shared = all -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enable-dav -- enable-proxy-ajp
# Make
# Make install

Start httpd and access http: // ip for testing (note that Port 80 must be enabled for iptables ):


Copy codeThe code is as follows:
#/Usr/local/apache2/bin/apachectl start

To disable access to a directory, you can create a. htaccess file under the Directory and enter the following content:


Copy codeThe code is as follows:
Order allow, deny
Deny from all

7. install php


Copy codeThe code is as follows:
# Tar xzf libxml2-2.7.5.tar.gz
# Cd libxml2-2.7.5
#./Configure -- prefix =/usr/local/libxml2
# Make
# Make install

# Cd ..
# Rpm-qa php
# Rpm-e -- nodeps -- allmatches php-5.1.6-27.el5
# Tar xzf php-5.3.1.tar.gz
# Cd php-5.3.1
#. /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
# Make
# Make install
# Cp php. ini-production/usr/local/php5/lib/php. ini

Modify the httpd. conf file:

1) add a line after AddType application/x-gzip. gz. tgz: AddType application/x-httpd-php. php
2) add index. php after DirectoryIndex index.html

Restart httpd to make php take effect!

8. install Tomcat 7


Copy codeThe code is as follows:
# Unzip-q apache-tomcat-7.0.23.zip
# Mv apache-tomcat-7.0.23 tomcat-7

Configure the tomcat virtual host, open the conf/server. xml configuration file, and add the following sections (add multiple sections as follows ):


Copy codeThe code is as follows:

UnpackWARs = "true" autoDeploy = "true">
Chinapis.com


After tomcat is configured, you also need to configure the apache VM File (conf/extra/httpd-vhosts.conf ):


Copy codeThe code is as follows:

DocumentRoot "/kington/webapps/chinapis"
ServerName www.bitsCN.com
ServerAlias bitsCN.com

ErrorLog "|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/bitsCN.com _ % Y-% m-% d_error_log 86400 480"
CustomLog "|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/bitsCN.com _ % Y-% m-% d_access_log 86400 480" common

ProxyPass/images /!
ProxyPass/styles /!

ProxyPreserveHost On
ProxyPass/ajp: // localhost: 8009/
ProxyPassReverse/ajp: // localhost: 8009/

The preceding configurations are described as follows:

1) ErrorLog and CustomLog configure the polling time of log files (86400 indicates that the second is a day, and 480 is the time zone offset)

III. FAQs

1. when compiling and installing php, the following error occurs: configure: error: libpng. (a | so) not found. first, install each dependent component (libjpeg, libpng, and freetype), and then perform the following processing:


Copy codeThe code is as follows:
# Ln-s/usr/lib64/libjpeg. so/usr/lib/
# Ln-s/usr/lib64/libpng. so/usr/lib/

2, decompress the bin format jdk when the error:/lib/ld-linux.so.2: bad ELF interpreter, need to install some of the missing files:


Copy codeThe code is as follows:
# Yum install ld-linux.so.2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.