nginx配置,php安装

yum -y install libxml2 libxml2-develyum -y install libxslt-devel
yum -y install bzip2-devel
yum -y install curl-devel
yum -y install libjpeg-devel #报什么错误缺少什么扩展请参与此文http:
//www.poluoluo.com/jzxy/201505/364819.html

 

# yum install -y pcre pcre-devel  
# yum install -y zlib zlib-devel  
# yum install -y openssl openssl-devel 
# yum install -y gcc gcc-c++
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
/usr/local/nginx/sbin/nginx  #启动
/usr/local/nginx/sbin/nginx -s reload #重启
/usr/local/nginx/sbin/nginx -t #配置文件是否正确

 

#
# The default server
#
server {
    listen 80;
    server_name localhost;
    root /usr/local/nginx/html;
    location / {
        index index.php index.html index.htm;
        if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
        }

        #if (-f $request_filename/index.php){
        #        rewrite (.*) $1/index.php;
        #}
        #if (!-f $request_filename){
        #        rewrite (.*) /index.php;
        #}
    }
    error_page 404 /404.html;
    location = /404.html {
        root /usr/local/nginx/html;
    }
    limit_rate_after 5m;
    limit_rate 512k;
    location ~ \.mp4$ {
        mp4;
        mp4_buffer_size 5m;
        mp4_max_buffer_size 20m;
    }
    location = /50x.html {
        root /usr/local/nginx/html;
    }

    location ~  ^/files/.*\.(php|php5)$ {
        deny all;
    }

    location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {
        expires 10y;
        access_log off;
        gzip off;
    }

    location ~* \.(css|js)$ {
        expires 10y;
        access_log off;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME                   $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS              off;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 8 128k;
    }


}

 

去掉了index.php,rewrite规则在第10行,如果多个php共存的话,改一下每个php的php-fpm.conf配置,将端口设置不同,再在这里面的fastcgi_pass里更改下需要运行的服务器及端口号。 

PHP安装:

更换yum源:https://yq.aliyun.com/articles/33286

下载地址:http://php.net/downloads.php

 如果是php7的编辑,不用--with-mysql这个选项

./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt=/usr/local/libmcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-pdo --with-pdo-mysql --with-gettext --with-curl --with-pdo-mysql --enable-sockets --enable-bcmath --enable-xml --with-bz2 --enable-zip --with-freetype-dir=/usr/include/freetype2/freetype/
#如果系统默认没有安装freetype
curl -O https://cytranet.dl.sourceforge.net/project/freetype/freetype2/2.3.9/freetype-2.3.9.tar.gz
tar -zxvf freetype-2.3.9.tar.gz
cd freetype-2.3.9
./configure --prefix=/usr/local/freetype
make && make install #安装GD2库或编辑php时,最后加上
--with-freetype-dir=/usr/local/freetype/选项,重新编绎PHP请先make clean

php 编辑过程出现各种依赖包错误请查看

#报什么错误缺少什么扩展请参与此文http://www.poluoluo.com/jzxy/201505/364819.html 特别全
php-fpm重启
ps aux | grep php-fpm
root     17326  0.0  0.4 219840  4924 ?        Ss   23:10   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody   17327  0.0  0.4 219840  4488 ?        S    23:10   0:00 php-fpm: pool www
nobody   17328  0.0  0.4 219840  4488 ?        S    23:10   0:00 php-fpm: pool www
root     17330  0.0  0.0 112660   968 pts/3    R+   23:10   0:00 grep --color=auto php-fpm
kill -USR2 17327  #kill掉master process

 

 

你可以使用--with-config-file-path=/etc
把php.ini存放到/etc下面,然后可以从源码包中拷贝php.ini-dist/php.ini-production到/etc/php.ini。

#添加 PHP 命令到环境变量
vim /etc/profile

#在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH

#要使改动立即生效执行
. /etc/profile 或 source /etc/profile

#查看环境变量
echo $PATH

#查看php版本
php -v 

PHP 5.5.38 (cli) (built: Jun 10 2017 11:11:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

#配置php-fpm
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf

 

 用yum安装的时候,默认在/etc/init.d/目录下面会有php-fpm或mysql,编辑安装的时候没有,这个时候需要自己增加服务到/etc/init.d/目录下,再设置开机启动

将nginx,php-fpm加入服务 http://www.jb51.net/article/58796.htm

Centos7 mysql安装参考: https://blog.csdn.net/li_wei_quan/article/details/78549891

 

posted @ 2015-06-30 19:20  斯世轻尘  阅读(410)  评论(0编辑  收藏  举报