总结:iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

 

下载php-5.6.27.tar.gz 在到/root目录下,并解压

 

[[email protected] ~]# tar -zxvf php-5.6.27.tar.gz

 

[[email protected] ~]# cd php-5.6.27

 

[[email protected] php-5.6.27]# ls

      

[[email protected] php-5.6.27]# ./configure --help

 

通过yum安装依赖。libxml2-devel是PHP编译安装所必需的依赖包,其余的是PHP各种扩展的依赖包。

 

[[email protected] php-5.6.27]#  yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel

 

Nginx安装PHP教程有这一篇就够啦

 

安装libmcrypt依赖

下载 libmcrypt-2.5.8.tar.gz(课件有)

[[email protected] ~]# tar -zxvf libmcrypt-2.5.8.tar.gz

[[email protected] ~]# cd libmcrypt-2.5.8

[[email protected] libmcrypt-2.5.8]# ./configure

[[email protected] libmcrypt-2.5.8]# make && make install

 

 

安装PHP

[[email protected] ~]# cd php-5.6.27

[[email protected] php-5.6.27]#./configure --prefix=/usr/local/php --enable-fpm --with-zlib --enable-zip --enable-mbstring --with-mcrypt --with-mysql --with-mysqli --with-pdo-mysql --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-curl --with-openssl --with-mhash --enable-bcmath --enable-opcache

 

[[email protected] php-5.6.27]# make &&make install

 

PHP的简单使用

(1)编写PHP代码如下。

<?php

    echo "Hello World !\n";

?>

通过“.php”文件执行PHP代码

[[email protected] ~]# /usr/local/php/bin/php -f test.php

Nginx安装PHP教程有这一篇就够啦

直接执行PHP代码

[[email protected] ~]# cd /usr/local/php/bin

[[email protected] bin]# ./php -r 'echo 100+200,"\n";'

Nginx安装PHP教程有这一篇就够啦

6、PHP-FPM

(1)复制PHP-FPM的配置文件

Nginx安装PHP教程有这一篇就够啦

(2)启动PHP-FPM

[[email protected] etc]# cd ~/php-5.6.27

[[email protected] php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[[email protected] php-5.6.27]# chmod +x /etc/init.d/php-fpm

[[email protected] php-5.6.27]# chkconfig --add php-fpm

 

[[email protected] ~]# service php-fpm start

[[email protected] ~]# service php-fpm reload

[[email protected] ~]# service php-fpm restart

[[email protected] ~]# service php-fpm stop

 

Nginx安装PHP教程有这一篇就够啦

7、PHP与Nginx整合

(1)以虚拟主机www.ng.test为例,修改配置文件如下

  server {

        listen 80;

        server_name www.ng.test;

        root  html/www.ng.test;

        index index.html index.htm index.php;

       

        location ~ \.php$ {

                fastcgi_pass 127.0.0.1:9000;

                include fastcgi.conf;

        }

 

}v

 

[[email protected] nginx]# nginx -s reload

目录www.ng.test下创建两个文件 test.php 和 index.php

[[email protected] nginx]# cd html

[[email protected] html]# mkdir www.ng.test

[[email protected] html]# cd www.ng.test

[[email protected] www.ng.test]# echo '<?php echo 123;' > test.php;

[[email protected] www.ng.test]# echo  ‘<?php phpinfo();' > index.php;

 

输入浏览器地址:

Nginx安装PHP教程有这一篇就够啦

 

Nginx安装PHP教程有这一篇就够啦

 

 

 

实验截图

Nginx安装PHP教程有这一篇就够啦

Nginx安装PHP教程有这一篇就够啦

Nginx安装PHP教程有这一篇就够啦

 

安装依赖

 

Nginx安装PHP教程有这一篇就够啦

 

 

3

Nginx安装PHP教程有这一篇就够啦

 

Nginx安装PHP教程有这一篇就够啦

 

安装PHP

Nginx安装PHP教程有这一篇就够啦

Clea

 

 

 

5php的简单使用

Nginx安装PHP教程有这一篇就够啦

 

Nginx安装PHP教程有这一篇就够啦

 

 

7

 

Nginx安装PHP教程有这一篇就够啦

 

 

 

 

Nginx安装PHP教程有这一篇就够啦

 

相关文章: