linux下宝塔lnmp和nginx的配置

1.nginx的安装以及配置


1.重启
service nginx reload 
service nginx restart 


2.添加yum源 centos 7.x
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm


3.配置完nginx后,需要对nginx进行检查
nginx -t


2.php的安装


1.yum 
yum search  搜索
yum list installed 安装列表
yum install    安装
yum remove     删除指定的包
yum下面php的安装
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
如果是centos6,那么执行以下代码: 
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
然后就可以直接yum安装php7.0了,可以安装的拓展如下:
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel


2.查看并启动fpm
ps -ef|grep fpm (查看fpm的进程)
ps用于查看当前进行,ps -ef用于查看当前所有的进程。

linux下宝塔lnmp和nginx的配置_第1张图片

可查到当前运行的php-fpm的配置是在/www/server/php/70/etc/php-fpm.conf下;完后查看/www/server/php/70/etc/php-fpm.conf:

linux下宝塔lnmp和nginx的配置_第2张图片

可看到当前监听的是/tmp/php-cgi-70.sock,并非是9000端口,所以后面配置的时候,就有了以下的改变:

#fastcgi_pass    127.0.0.1:9000;
fastcgi_pass    unix:/tmp/php-cgi-70.sock;


启动服务
service php-fpm start


3.安装上传 lrzsz
yum -y install lrzsz


4.权限修改
chmod –R 777 *


5.修改文件的组和权限
[root@vultr wwwroot]# chgrp 1000 laravel -R
[root@vultr wwwroot]# chown 1000 laravel -R
chmod -R 000


6.解压 微信到demowx文件下
unzip 微信.zip -d demowx  
 

最后Nginx的配置如下:
Http:

server {
    listen       80;
    server_name  dd.com;
    root    "D:/phpstudy/PHPTutorial/WWW";

    location / {
        index  index.html index.htm index.php;
        if ( -f $request_filename) {
            break;
        }
        if ( !-e $request_filename) {
            rewrite ^(.*)$ /index.php/$1 last;
            break;
        }
    }

    location ~ \.php(.*)$  {
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass  unix:/tmp/php-cgi-70.sock;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
}

Https:

server {
        listen 443;
        server_name 106.12.5.245 www.goubaobao.club pai.goubaobao.club;
        ssl on;
        ssl_certificate /www/server/panel/vhost/nginx/www.goubaobao.club.crt;
        ssl_certificate_key /www/server/panel/vhost/nginx/www.goubaobao.club.key;
        set        $root    /www/wwwroot/pai/public;
        location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)${
            root $root;
        }
        location / {
                root    $root;
                index    index.html index.php;
                if ( -f $request_filename) {
                     break;
                }
                if ( !-e $request_filename) {
                    rewrite ^(.*)$ /index.php/$1 last;
                    break;
                }
       }
    location ~ .+\.php($|/) {
        set $script $uri;
        set $path_info "";
        if ($uri ~ "^(.+\.php)(/.+)") {
            set $script $1;
            set $path_info $2;
        }
        fastcgi_pass  unix:/tmp/php-cgi-70.sock;
        fastcgi_index    index.php?IF_REWRITE=1;
        fastcgi_param    PATH_INFO    $path_info;
        fastcgi_param    SCRIPT_FILENAME    $root$fastcgi_script_name;
        fastcgi_param    SCRIPT_NAME    $script;
        include        fastcgi_params;
    }
}

 

你可能感兴趣的:(Linux)