分类: LINUX
2014-01-15 13:09:41
环境:
HTTPD下载:
MYSQL下载:
PHP 下载 :
Centos下载 :
Awstat下载:
Perl下载:
1、安装常用的依赖包:
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre
2、下载:(apr-1.4.5.tar.gz apr-util-1.3.12.tar.gz 、pcre-8.21.tar.bz2)
[root@yahoo home]# tar -zxf apr-1.4.5.tar.gz
[root@lamp apr-1.4.5]# ./configure --prefix=/usr/local/apr
[root@lamp apr-1.4.5]# make
[root@lamp apr-1.4.5]# make install
[root@lamp home]# tar -zxf apr-util-1.3.12.tar.gz
[root@lamp apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@lamp apr-util-1.3.12]# make
[root@lamp apr-util-1.3.12]# make install
[root@lamp home]# tar jxvf pcre-8.21.tar.bz2
[root@lamp pcre-8.21]# ./configure --prefix=/usr/local/pcre
[root@lamp pcre-8.21]# make
[root@lamp pcre-8.21]# make install
3、编译安装apache (这里用的是2.4.4版本):
[root@lamp home]# tar zxvf httpd-2.4.4.tar.gz -C /usr/src/
[root@lamp home]# cd /usr/src/httpd-2.4.4/
[root@lamp httpd-2.4.4]#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/lib --enable-auth-digest --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache/htdocs --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
[ httpd-2.4.1]# make && make install
[root@lamp httpd-2.4.1]# vi /usr/local/apache/conf/httpd.conf
ServerName localhost (不修改也行默认是#注释的)
[root@lamp httpd-2.4.1]#/usr/local/apache/bin/apachectl start
IP/ (验证)
4、http压力测试:系统自带的ab 工具:
格式:ab [-q] –c 并发数 –n 总请求书数 [http://] 域名 [:端口]/路径
修改最大请求数:
[root@lamp bin]# ulimit -a | grep "open files" (查看、默认为1024)
open files (-n) 1024
[root@lamp bin]# ulimit -n 10000 (修改为1万)
[root@lamp bin]# /usr/local/apache/bin/ab -q -c 2000 -n 6000 /
二、编译配置mysql(这里是5.5.28版本):
1、安装bison和cmake
提示:MySQL 5.5 版本的安装需要这两个软件,bison我们可以用方便的yum直接安装好,cmake则用编译安装的办法。
[root@lamp home]# yum -y install bison
[root@lamp home]# wget
(CP cmake 到 /usr/bin 下)
[root@lamp cmake-2.8.4]# cp /usr/local/bin/cmake /usr/bin
[root@lamp home]# tar zxvf mysql-5.5.15.tar.gz -C /usr/src/
[root@lamp home]# cd /usr/src/mysql-5.5.15
3、(创建用户)
[root@lamp mysql-5.5.28]# useradd -M -s /sbin/nologin mysql
4、(在根目录下创建mysql库)
[root@lamp mysql-5.5.28]# mkdir /data/mysql/
[root@lamp mysql-5.5.28]# chown -R mysql:mysql /data/mysql
[root@lamp mysql-5.5.28]# chown –R root:mysql /usr/local/mysql
5、(编译)
[root@lamp mysql-5.5.28]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/
6、(安装)
[root@lamp mysql-5.5.28 ]# make && make install
7、(复制配置文件模板为配置文件)
[root@lamp mysql-5.5.28 ]# cp support-files/my-medium.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
8、(编辑my.cnf)
[root@ lamp mysql]# vi /etc/my.cnf
9、(在 [mysqld] 段增加)
datadir = /data/mysql
wait-timeout = 30
max_connections = 512
max_connect_errors = 10000000
default-storage-engine = MyISAM
10、在 [mysqld] 段修改
max_allowed_packet = 16M
11、(启动文件CP到service启动支持)
[root@ lamp mysql-5.5.28 ]# cp support-files/mysql.server /etc/init.d/mysqld
cp: overwrite `/etc/init.d/mysqld'? y
12、(编辑mysqld)
[root@ lamp mysql-5.5.28 ] vi /etc/init.d/mysqld
把basedir=编辑成basedir=/usr/local/mysql
把datadir=编辑成datadir=/data/mysql
[root@ lamp mysql-5.5.28 ]# chmod a+x /etc/init.d/mysqld
[root@lamp mysql-5.5.28 ]# chkconfig --add mysqld
[root@lamp mysql-5.5.28 ]# chkconfig --level 3 mysqld on
[root@lamp mysql-5.5.28 ]# cd /usr/local/mysql/
[root@lamp mysql]# .scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql/ &
[root@lamp ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[root@lamp mysql]# service mysqld start
Starting MySQL[ OK ]
注释:[ERROR] Can't start server: Bind on TCP/IP port: Address already in use
130513 0:45:00 [ERROR] Do you already have another mysqld server running on port: 3306 ?
130513 0:45:00 [ERROR] Aborting
以上错误可修改/etc/my.cnf 文件中 port号来调整
另外/data/mysql/文件 需手动建立
13、(写入变量方便命令实用)
[root@lamp ~]# export PATH=$PATH:/usr/local/mysql/bin/
[root@lamp ~]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
14、(设置root密码)
[root@lamp ~]# mysqladmin -uroot password "123456"
15、(创建mysql用户)
mysql> GRANT ALL PRIVILEGES ON *.* TO yhby@'%' IDENTIFIED BY "123456";
Query OK, 0 rows affected (0.07 sec)
三、编译安装PHP(这里是5.4.14版本的):
[root@lamp home]# tar zxvf php-5.4.0.tar.gz -C /usr/src/
[root@lamp php-5.4.14]# cd /usr/src/php-5.4.0/
1、开始编译:
[root@lamp php-5.4.14 ]# ./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php
[root@lamp php-5.4.14 ]# make && make install
[root@lamp php-5.4.14 ]# cp php.ini-production /usr/local/php/php.ini
[root@lamp php-5.4.14 ]# vi /usr/local/apache/conf/httpd.conf
LoadModule php5_module modules/libphp5.so (必须有 木有的话从新编译PHP)
1-2、添加:
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
2、建立测试页:
[root@lamp php-5.4.0]# vi /usr/local/apache/htdocs/xxoo.php
phpinfo();
?>
3、重启apache服务后
4、测试: Adress /xxoo.php
#############看到后ok######################