文章来源:http://www.cnblogs.com/hello-tl/p/7569071.html
更新时间:2017-09-21 16:03
简介
LAMP+R指Linux+Apache+Mysql+PHP+Redis是一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。
Apache 安装篇 Demo地址:http://www.cnblogs.com/hello-tl/articles/7568803.html
Php 安装篇 Demo地址:http://www.cnblogs.com/hello-tl/p/7569071.html
Mysql 安装篇 Demo地址:http://www.cnblogs.com/hello-tl/p/7569097.html
Redis 安装篇 Demo地址:http://www.cnblogs.com/hello-tl/p/7569108.html
0、yum 安装依赖和工具 和 libmcrypt 包
# yum install gcc gcc++ libxml2-devel
# yum install openssl openssl-devel
# yum -y install curl-devel
# yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
# yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar -zxvf libmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure --prefix=/home/libmcrypt
# make install
# /home/libmcrypt/bin/libmcrypt-config --version
# /home/libmcrypt/lib/libmcrypt.la
# rpm -qa libmcrypt
# yum install libmcrypt
# yum install libmcrypt libmcrypt-devel mcrypt mhash.
//可能会报错 I was not able to diagnose which libmcrypt version you have installed
# yum install epel-release //扩展包更新包
# yum update //更新yum源
1.下载php安装包及安装PHP
# wget http://hk1.php.net/get/php-7.1.6.tar.gz/from/this/mirror # mv mirror php-7.1.6.tar.gz # tar -zxvf php-7.1.6.tar.gz # cd php-7.1.6.tar.gz # ./configure --prefix=/home/php7 --with-apxs2=/home/apache/bin/apxs --exec-prefix=/home/php7 --bindir=/home/php7/bin --sbindir=/home/php7/sbin --includedir=/home/php7/include --libdir=/home/php7/lib/php --mandir=/home/php7/php/man --with-config-file-path=/home/php7/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --with-mcrypt=/home/libmcrypt --with-libdir=lib64 --disable-fileinfo # make && make install
2.创建php.ini文件
# cp php.ini-development /home/php7/lib/php.ini
3.查看php是否安装成功
# cd .. # vim index.php <?php echo phpinfo(); # /home/php7/bin/php index.php
4.apache支持php
1).编辑httpd.conf文件 # vim /home/apache/conf/httpd.conf (1).找到 AddType 最下面添加 AddType application/x-httpd-php .php (2).找到 DirectoryIndex index.html DirectoryIndex index.php index.html index.htm (3).找到 ServerName www.example.com:80 ServerName 127.0.0.1:80或者ServerName localhost:80 (4).默认的目录为 "/home/apache/htdocs",默认目录修改apache的配置文件httpd.conf
5.php扩展
echo "extension_dir=/home/php7/lib/php/extensions/no-debug-zts-20160303/" >> /home/php7/etc/php.ini 1).pcntl # cd /home/installPare/php7/php-7.1.6/ext/pcntl # /home/php7/bin/phpize # ./configure --with-php-config=/home/php7/bin/php-config # make && make install # echo "extension=pcntl.so" >> /home/php7/etc/php.ini 2).mysqli # cd /home/installPare/php7/php-7.1.6/ext/mysqli # /home/php7/bin/phpize # ./configure --with-php-config=/home/php7/bin/php-config --with-mysqli=/usr/bin/mysql_config # make && make install # echo "extension=mysqli.so" >> /home/php7/etc/php.ini # echo "extension=pdo_mysql.so" >> /home/php7/etc/php.ini
6.判断Apache支持Php是否成功 / 扩展是否成功
# cd /home/apache/htdocs
# vim index.php
<?php echo phpinfo();
esc :x //保存退出
浏览器上输入IP地址测试