CentOS 6.2系统安装和基本软件环境配置

2020-01-30 13:18:52王冬梅

# groupadd mysql
# useradd -g mysql 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 -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
# make
# make install

配置Mysql,进行如下操作:


复制代码
# 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

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


复制代码
# /etc/init.d/mysql start 或 service mysql start
# /usr/local/mysql5/bin/mysqladmin -uroot password 'root'

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


复制代码
export PATH=/usr/local/mysql5/bin:$PATH

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


复制代码
mysql>show VARIABLES LIKE '%conn%';

6、安装httpd


复制代码
# 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-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-dav --enable-proxy --enable-proxy-ajp
# make
# make install

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


复制代码
# /usr/local/apache2/bin/apachectl start

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


复制代码
order allow,deny
deny from all

7、安装php


复制代码
# 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