1.YUM安装Apacche
yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof
yum install -y httpd httpd-devel
查看Apache版本信息:
apachectl -v
列出Apache相关安装内容:
rpm -qa | grep httpd
2.安装PHP。
apache对PHP的支持是通过apache的mod_php5模块来支持的,这点与nginx不同。nginx是通过第三方的fastcgi处理器才可以对php进行解析。
如果源码编译安装php的话,需要在编译时指定--with-apxs2=/usr/local/apache2/bin/apxs表示告诉编译器通过apache的mod_php5模块来提供对php的解析。
同时php安装的最后一步make install时,我们会看到将动态链接库libphp5.so拷贝到apache2的安装目录的modules目录下,并且还需要在 httpd.conf配置文件中添加LoadModule语句来动态将libphp5.so模块加载进来,从而实现Apache对php的支持。
下载:
wget http://cn2.php.net/get/php-5.5.35.tar.gz/from/this/mirror
修改名字&&解压:
mv mirror php-5.5.35.tar.gz && tar xvf php-5.5.35.tar.gz
进入目录:
cd php-5.5.35
显示当前目录:
编译:
./configure --prefix=/usr/local/php --with-apxs2=/usr/bin/apxs --with-config-file-path=/usr/local/php/etc -with-fpm-user=apache --with-fpm-group=apache --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-iconv-dir --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir= --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-kerberos --with-imap=/usr/lib64 --with-imap-ssl
PHP cofigure参数解释:
--prefix=/usr/local/php-5.5.35 //php安装路径 --with-apxs2=/usr/bin/apxs //apxs程序所在路径,默认/usr/bin/apxs或/usr/local/bin/apxs --with-config-file-path=/usr/local/php-5.5.35/etc //php配置文件路径 --with-bz2 //支持bz2压缩 --with-curl --enable-ftp --enable-sockets //PHP支持套接字 --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local //jpeg图片生成工具 --with-png-dir=/usr/local //png图片生成工具 --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local //指定xml库目录 --with-zlib //让数据文件先压缩在传送 --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd //php访问mysql的另外一种机制 --with-mysql=mysqlnd //编译使用mysql驱动指明路径,如果是rpm包安装的mysql只需写--with-mysql --enable-dom --enable-xml //启用xml功能 --enable-fpm //以fpm方式运行 --with-libdir=lib64 --enable-bcmath
编译并安装:
make && make install
安装完成,程序自动将编译完的so文件放到/usr/lib64/httpd/modules/libphp5.so并在Apache的主配置文件/etc/httpd/conf/httpd.conf中引入php5。
自动
测试:
#echo "<?php phpinfo(); ?>" > /var/www/html/index.php
在浏览器里 打开网页看能不能显示PHP信息。路径:http://你的IP/index.php 如果显示PHP版信息的紫色界面就说明安装成功了。
PHP服务:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf # cp php.ini-devlopment /usr/local/php/etc/php.ini # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm
并发数压力测试: 用Apache自带的ab
ab -n 5000 -c 100
测试结果
Requests per second: 263.38 [#/sec] (mean) Time per request: 379.675 [ms] (mean) Time per request: 3.797 [ms] (mean, across all concurrent requests)
3.安装MYSQL
参考文章:
http://www.cnblogs.com/mrwang1101/p/5513158.html
https://zhidao.baidu.com/question/332795586.html
http://blog.csdn.net/jespere_ling/article/details/49493619
http://blog.csdn.net/yuanyuan_186/article/details/51316799
http://5990383.blog.51cto.com/5980383/1655276
http://blog.csdn.net/gumingyaotangwei/article/details/26092315