FastCGI像是一个常驻(long-live)型的CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去fork一次(这是CGI最为人诟病的fork-and-execute 模式)。它还支持分布式的运算, 即 FastCGI 程序可以在网站服务器以外的主机上执行并且接受来自其它网站服务器来的请求。 mysql源码 然后解压进行安装 在之前先建个mysql账号mysql组(有了则不需要建立) [iyunv@wang ~]# groupadd mysql [iyunv@wang ~]# useradd -r -g mysql mysql [iyunv@wang ~]# rpm -qa |grep mysql 查看之前安装 与mysql想关的包,删除 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media remove mysql-libs 软件包移除 [iyunv@wang ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local 进行解压 [iyunv@wang ~]# cd /usr/local/src cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 进行编译 make && make install 编译安装 [iyunv@wang local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql 做个链接 [iyunv@wang local]# cd mysql [iyunv@wang mysql]# vim INSTALL-BINARY 可以查看帮助文件进行安装 shell> groupadd mysql shell> useradd -r -g mysql mysql shell> cd /usr/local shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz shell> ln -s full-path-to-mysql-VERSION-OS mysql shell> cd mysql shell> chown -R mysql . shell> chgrp -R mysql . shell> scripts/mysql_install_db --user=mysql shell> chown -R root . [iyunv@wang mysql]# chown -R mysql:mysql . 改变当前目录所有者与所有组为mysql [iyunv@wang mysql]# ./scripts/mysql_install_db --user=mysql 进行安装 如果出现这样的错误就需要安装libaio [iyunv@wang mysql]# yum --disablerepo=* --enablerepo=c6-media install libaio libaio-devel -y 进行安装 [iyunv@wang mysql]# ./scripts/mysql_install_db --user=mysql 重新安装 [iyunv@wang mysql]# cd data/ [iyunv@wang data]# ll mysql/ 查看mysql目录下是否有数据,有数据的话表明安装成功 [iyunv@wang data]# cd .. 进入mysql目录 [iyunv@wang mysql]# chown -R root . 改变当前所有用户为管理员 [iyunv@wang mysql]# chown -R mysql data/ 将data用户改为mysql [iyunv@wang mysql]# cp my.cnf /etc copy文件到my.cnf [iyunv@wang mysql]# cd support-files/ [iyunv@wang support-files]# cp -p mysql.server /etc/init.d/mysqld 复制mysql文件到mysqld下
[iyunv@wang support-files]# service mysqld start 测试是否能够启动 [iyunv@wang mysql]# vim /etc/profile 修改配置文件
PATH=$PATH:/usr/local/mysql/bin 添加此语句 [iyunv@wang mysql]# . /etc/profile 重新读取 [iyunv@wang mysql]# mysql 进入mysql [iyunv@wang mysql]# mysqladmin -u root -p password '123' 设置mysql密码 [iyunv@wang mysql]# chkconfig --add mysql 启动系统启动 [iyunv@wang mysql]# chkconfig mysqld on [iyunv@wang mysql]# vim /etc/ld.so.conf.d/mysql.conf 编辑mysql配置文件
写入此路径 [iyunv@wang mysql]# ldconfig 刷新缓存 [iyunv@wang mysql]# ldconfig -pv |grep mysql 查看结果
[iyunv@wang mysql]# cd /usr/include/ 进入目录 [iyunv@wang include]# ln -s /usr/local/mysql/include/ mysql 做一个链接 [iyunv@wang mysql]# vim /etc/man.config 处理man手册
MANPATH /usr/local/mysql/man 加入即可 [iyunv@wang mysql]# man mysql 进行测试 Mysql处理成功 然后进行apach的安装 httpd-2.4.4.tar.bz2 apr-1.4.6.tar.gz apr-1.4.6.tar.gz 需要这3个软件包 [iyunv@wang ~]# tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src/ 解压apr软件包 [iyunv@wang ~]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/ 解压aprutil软件包 [iyunv@wang ~]# tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/ 解压httpd软件包 [iyunv@wang ~]# cd /usr/local/src/apr-1.4.6/ 进入apr目录 [iyunv@wang apr-1.4.6]# ./configure --prefix=/usr/local/apr 进行编译 [iyunv@wang apr-1.4.6]# make && make install 安装 [iyunv@wang apr-1.4.6]# cd ../apr-util-1.5.1/ 切换到apr-util目录 [iyunv@wang apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-utils --with-apr=/usr/local/apr/bin/apr-1-config 编译,指定工具安装路径,指定apr的路径 [iyunv@wang apr-util-1.5.1]# make && make install 进行编译安装 [iyunv@wang apr-util-1.5.1]# cd ../httpd-2.4.4/ 配置httpd ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-utils/bin/apu-1-config --with-pcre -with-z --enable-mpms-shared=all 进行编译配置
出现错误提示,需要安装pcre-devel包 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install pcre-devel -y 安装包 然后再进行编译配置
出现这个错误提示,需要安装[iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install openssl-devel -y 再进行编译配置通过后 [iyunv@wang httpd-2.4.4]# make && make install 配置安装 完成后 [iyunv@wang httpd-2.4.4]# cd /usr/local/apache/ 进入apache目录 [iyunv@wang apache]# vim /etc/profile 编辑profile文件
/usr/local/apache/bin 增加新的路径 [iyunv@wang apache]# . /etc/profile 进行更新 [iyunv@wang apache]# httpd -k start 测试是否能启动 [iyunv@wang apache]# netstat -tupln |grep 80 查看80端口是否开启 [iyunv@wang apache]# vim /etc/man.config 编辑man配置文件
加入MANPATH /usr/local/apache/man [iyunv@wang apache]# man ab 尝试下是否生效 [iyunv@wang apache]# cd /usr/include/ 进入include目录 [iyunv@wang include]# ln -s /usr/local/apache/include/ apache 做个链接 [iyunv@wang ~]# cd /etc/init.d/ 进入目录 [iyunv@wang init.d]# touch httpd 创建httpd文件 [iyunv@wang init.d]# chmod a+x httpd 加入可执行权限 [iyunv@wang init.d]# vim httpd 进行编辑 #!/bin/bash 2 prog=/usr/local/apache/bin/httpd 3 lockfile=/var/lock/subsys/httpd 4 # description: the apache service 5 # chkconfig: 2345 88 44 6 start(){ 7 if [ -e $lockfile ];then 8 echo "the apache service is started" 9 else 10 echo -n "the apache service is starting ...." 11 sleep 1 12 $prog -k start && echo "ok" && touch $lockfile || echo "failer" 13 fi 14 15 } 16 17 stop(){ 18 if [ !e $lockfile ];then 19 echo "the apache service is stopped" 20 else 21 echo "the apache service is stoping..." 22 $prog -k stop && echo "ok" && rm -rf $lockfile || echo "failer" 23 fi 24 25 } 26 27 28 case "$1" in 29 start) 30 start 31 ;; 32 stop) 33 stop 34 ;; 35 restart) 36 stop 37 start 38 ;; 39 *) 40 echo "Usage: start|stop|restart" 41 ;; 42 esac 添加此代码来实现httpd启动关闭动态效果 [iyunv@wang init.d]# chkconfig --add httpd 加入httpd服务 [iyunv@wang init.d]# chkconfig --list |grep httpd 查看服务启动
[iyunv@wang ~]# cd /usr/local/apache/ 进入apache目录 root@wang apache]# cd modules/ [iyunv@wang modules]# ll |grep proxy 查看是否有与proxy相关的模块 [iyunv@wang modules]# vim /etc/httpd/httpd.conf 进入配置文件
打开proxy模块和fcgi模块 [iyunv@wang modules]# service httpd restart 重启httpd Php安装 需要安装的包 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install libcm12-devel libjpeg-turbo-devel libpng-devel freetype-devel -y root@wang ~]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src/ 解压软件包 [iyunv@wang ~]# cd /usr/local/src/php-5.5.8/ [iyunv@wang php-5.5.8]# ./configure > --prefix=/usr/local/php > --enable-fpm > --enable-sockets > --with-mysql=/usr/local/mysql > --with-pdo-mysql=/usr/local/mysql > --with-mysqli=/usr/local/mysql/bin/mysql_config > --enable-mbstring > --enable-xml > --with-png-dir > --with-gd > --with-jpeg-dir > --with-zlib > --with-freetype-dir > --with-config-file-path=/etc/php > --with-config-file-scan-dir=/etc/php5.d 配置安装 出现 需要安装[iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install libjpeg* -y 出现
需要安装[iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install libpng-devel -y 出现
需要安装 [iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install freetype* -y 出现什么就 rpm -qa |grep 包名 找到包安装其devel包即可
接下来需要make && make isntall 因为时间比较长,睡眠的时候可能连接断开所以需要screen来实现安装 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install screen -y 安装screen [iyunv@wang php-5.5.8]# screen 使用screen 又打开了一个窗口 ctrl+a+d可以离开 screen -ls可以查看 恢复的话 screen -r 编号 [iyunv@wang php-5.5.8]# make && make install 然后进行后台配置安装 因为要把php座位单独的服务器,所以需要 [iyunv@wang php-5.5.8]# cd sapi/ [iyunv@wang sapi]# cd fpm/ [iyunv@wang fpm]# grep -E "start|stop|restart" * 查找哪个文件是配置文件 [iyunv@wang fpm]# cp init.d.php-fpm /etc/init.d/php-fpm 将配置文件拷贝到php-fpm目录 [iyunv@wang fpm]# chmod a+x /etc/init.d/php-fpm 给予可执行权限 [iyunv@wang fpm]# service php-fpm start 尝试启动下
显示缺少配置文件 [iyunv@wang fpm]# cd /usr/local/php/ [iyunv@wang php]# cd etc/ 进入安装目录 [iyunv@wang etc]# cp php-fpm.conf.default php-fpm.conf 将默认配置文件拷贝成正式的配置文件 [iyunv@wang etc]# service php-fpm start 再次重启下 [iyunv@wang etc]# netstat -tupln|grep php tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8885/php-fpm 查找php-fpm进程是9000.端口说明正确安装 [iyunv@wang etc]# chkconfig --add php-fpm 加入指定启动阵列 [iyunv@wang etc]# chkconfig php-fpm on 加入开机启动 [iyunv@wang etc]# mkdir /etc/php /etc/php5.d 创建2个目录 [iyunv@wang etc]# cd /usr/local/src/php-5.5.8/ 进入php源码目录 [iyunv@wang php-5.5.8]# ll |grep ini 查找是否有与ini相关的文件 [iyunv@wang php-5.5.8]# cp php.ini-production /etc/php/php.ini 将文件拷贝到php目录下 [iyunv@wang php-5.5.8]# service php-fpm restart 重新启动php-fpm 然后需要设置反向代理,将访问返回至127.0.0.1 9000端口给php-fpm [iyunv@wang php-5.5.8]# vim /etc/httpd/httpd.conf 打开apach配置文档
添加如上信息 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps ProxyRequests Off //关闭正向代理 ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1 //请求为php类型进行反向代理
点名首页为 index.php [iyunv@wang php-5.5.8]# service httpd restart 重启apache [iyunv@wang php-5.5.8]# cd /usr/local/apache/htdocs/ 进入apache主目录 [iyunv@wang htdocs]# vim index.php 做个测试页面
即如此,调用phpinfo()函数 然后登陆进行测试
成功 查看是否能够连接数据库 [iyunv@wang htdocs]# vim index.php 编辑网页文件
为如此即可
然后进行连接测试
显示ok,能够连接数据库 [iyunv@wang htdocs]# service mysqld stop 停止数据库进行测试
显示not,无法连接数据库,正确 然后放入php动态网页就行测试
将这2个软件进行解压测试 [iyunv@wang ~]# unzip phpwind_v9.0_gbk 解压wind [iyunv@wang ~]# cd phpwind_v9.0_gbk [iyunv@wang phpwind_v9.0_gbk]# mv upgrade/ /usr/local/apache/htdocs/phpwind 将文件移动到apache根目录 然后进行访问
成功访问
需要修改权限 [iyunv@wang phpwind]# chmod -R o+w html/ src/ attachment/ data/ template/ windid conf/ thems/ 刷新即可
然后设置必要的数据 可以使用,然后测试其他的页面 [iyunv@wang ~]# unzip phpMyAdmin-4.1.5-all-languages.zip 解压此包 [iyunv@wang ~]# mv phpMyAdmin-4.1.5-all-languages /usr/local/apache/htdocs/phpmyadmin 移动目录 然后进行访问
成功访问 然后输入账号密码就能访问数据库了
然后进行压力测试 [iyunv@wang php-5.5.8]# ab -n 1000 -c 500 http://192.168.2.50/phpmyadmin
800多 再测试一下 加入缓存测试下
解压xcache软件包 [iyunv@wang ~]# tar -zxvf xcache-3.1.0.tar.gz -C /usr/local/src/ [iyunv@wang ~]# cd /usr/local/src/xcache-3.1.0/ 进入解压的文件 [iyunv@wang xcache-3.1.0]# /usr/local/php/bin/phpize 用工具做成php的扩展 执行过后将出现configure [iyunv@wang xcache-3.1.0]# ./configure --help|grep -E "xcache|php" 查询关于xcache和php的配置方法 [iyunv@wang xcache-3.1.0]# ./configure --enable-xcache- -with-php-config=/usr/local/php/bin/php-config 进行配置 [iyunv@wang xcache-3.1.0]# make && make install 配置安装 [iyunv@wang xcache-3.1.0]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 进入目录查看下模块 [iyunv@wang no-debug-non-zts-20121212]# ls opcache.a opcache.so xcache.so 成功 [iyunv@wang no-debug-non-zts-20121212]# cp xcache.so /etc/php5.d/ 把模块移动到php5.d目录下 [iyunv@wang no-debug-non-zts-20121212]# cd /usr/local/src/xcache-3.1.0/ [iyunv@wang xcache-3.1.0]# ll |grep ini 查找ini相关的文件 [iyunv@wang xcache-3.1.0]# cp xcache.ini /etc/php5.d/ 将配置文件拷贝到此目录下 [iyunv@wang htdocs]# vim /etc/php5.d/xcache.ini 可以查看进行的配置 [iyunv@wang htdocs]# service php-fpm restart 重启php-fpm 然后浏览器进入网页测试下xcache是否加载成功
由此可看出xcache.ini 被成功加载
Xcache搜索能搜到 缓存做成后,重新进行压力测试 [iyunv@wang htdocs]# ab -n 1000 -c 500 http://192.168.2.50/phpmyadmin
速度明显提高
|