nginx php mysql安装和部署


安装mysql很简单,我用的是centos系统 安装mysql可以用yum命令安装

yum install -y mysql-server mysql-devel mysql


安装php

安装php麻烦的地方是在configure的时候选项的配置

如果php版本是5.2.x 还需要安装php-fpm

先下载php-fpm代码,解压之后给php源码打补丁

gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1 

在./configure的时候加上--enable-fpm选项

如果php是5.3.x以上版本,则不需要给php源码打补丁,只需要在./configure的时候加上--enable-fpm就可以了

由于我是64位系统 安装mysql的时候 *.so的文件会在lib64的文件夹下,在./configure时需要指明lib64,--with-libdir=lib64

./configure --prefix=/usr/local/php --enable-fpm  --with-mysql=/usr --with-pdo-mysql=/usr --with-libdir=lib64 --with-mysqli=/usr/bin/mysql_config

这里顺便说下 如果安装php的mysql驱动时 可以不需要使用mysql自带的libmysql驱动,也可以使用php自己的驱动

如果使用mysql的驱动,则./configure的时候需要加上选项

--with-mysql=/usr(注意如果系统是64位 还需要加上--with=libdir=64)

如果使用自带的mysql驱动 可以使用如下选项

--with-mysql=mysqlnd

--with-mysqli=mysqlnd

--with-pdo-mysql=mysqlnd


完全命令就是

./configure --prefix=/usr/local/php --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd


编译完之后

make

make install

这时候就可以在目录/usr/local/php中看到我们安装的php,但是现在还不能用php这个命令,需要设置PATH环境变量

vi /etc/profile

在文件末尾加上

export PHP_PATH=/usr/local/php

export PATH=$PATH:$PHP_PATH/bin:$PHP_PATH/sbin

添加完之后保存,输入一下命令生效

source /etc/profile

安装nginx

安装nginx很简单,可以用yum install nginx ,也可以用nginx源码编译安装

从官方下载nginx源码

解压后进入文件夹下

./configure --prefix=/usr/local/nginx

make

make install

同样会在/usr/local/nginx下看到我们安装的nginx

设置下PATH环境变量

vi /etc/profile

在文件末尾加上

export NGINX_PATH=/usr/local/nginx

export PATH=$PATH:$NGINX_PATH/sbin

添加完之后保存,输入一下命令生效

source /etc/profile



配置nginx

nginx需要使用fastcgi来解析php程序,使用nginx之前 需要开启php-fpm程序

php-fpm

nginx.conf配置如下:

location / {
            index  index.html index.php;
            root   /opt/web/php/test;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            root   /opt/web/php/test;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

来自:Nginx php mysql安装和部署安装mysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值