安装 apache
安装 apache 依赖于apr,apr-util,pcre shell> tar zxvf httpd-2.4.12.tar.gz shell> tar zxvf apr-1.5.1.tar.gz shell> tar zxvf apr-util-1.5.4.tar.gz shell> tar zxvf pcre-8.36.tar.gz shell> mv apr-1.5.1 httpd-2.4.12/srclib/apr shell> mv apr-util-1.5.4 httpd-2.4.12/srclib/apr-util shell> cd pcre-8.36 shell> ./configure --prefix=/usr/local/pcre shell> make && make install shell> cd ../httpd-2.4.12 shell> ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre --enable-so shell> make && make install 测试 shell> /usr/local/apache2/bin/apachectl start shell> ps -ef |grep httpd root 1872 1 0 17:24 ? 00:00:00 /usr/local/apache2/bin/httpd -k start daemon 1873 1872 0 17:24 ? 00:00:00 /usr/local/apache2/bin/httpd -k start daemon 1874 1872 0 17:24 ? 00:00:00 /usr/local/apache2/bin/httpd -k start daemon 1875 1872 0 17:24 ? 00:00:00 /usr/local/apache2/bin/httpd -k start 浏览器访问该IP显示`It works!`
安装 php
安装依赖包 shell> yum install automake autoconf libtool bison libxml2 libxml2-devel shell> xz -d php-5.5.23.tar.xz shell> tar xvf php-5.5.23.tar shell> cd php-5.5.23 shell> ./configure --prefix=/usr/local/php --enable-fpm --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs shell> make && make install chmod 755 /usr/local/apache2/modules/libphp5.so [activating module `php5' in /usr/local/apache2/conf/httpd.conf] Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20121212/ Installing PHP CLI binary: /usr/local/php/bin/ Installing PHP CLI man page: /usr/local/php/php/man/man1/ Installing PHP FPM binary: /usr/local/php/sbin/ Installing PHP FPM config: /usr/local/php/etc/ Installing PHP FPM man page: /usr/local/php/php/man/man8/ Installing PHP FPM status page: /usr/local/php/php/php/fpm/ Installing PHP CGI binary: /usr/local/php/bin/ Installing PHP CGI man page: /usr/local/php/php/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/php/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.3.12 [PEAR] Console_Getopt - installed: 1.3.1 [PEAR] Structures_Graph- installed: 1.0.4 [PEAR] XML_Util - installed: 1.2.3 [PEAR] PEAR - installed: 1.9.5 Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path /tool/php-5.5.23/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo/
配置Apache支持php
修改默认路径 shell> mkdir -p /var/www shell> vi /usr/local/apache2/conf/httpd.conf =================================================== # 添加模块 LoadModule rewrite_module modules/mod_rewrite.so LoadModule deflate_module modules/mod_deflate.so LoadModule php5_module modules/libphp5.so # 修改文件根目录 DocumentRoot "/var/www" DirectoryIndex index.php index.html # 添加apache对php支持 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps ===================================================
测试
shell> vi /var/www/index.php =================================================== phpinfo(); ?> =================================================== 重新通过浏览器访问该IP显示`PHP Version 5.5.23`
参考:
http://www.cnblogs.com/fly1988happy/archive/2011/12/14/2288096.html
整理自网络
Svoid
2015-04-18
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29733787/viewspace-1585540/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29733787/viewspace-1585540/