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用于查看当前所有的进程。
启动服务
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  


原始
server {
        listen 80;
        server_name 140.82.0.240;
        root /www/wwwroot/aaa/public;
        index index.php index.html index.htm;
        access_log /www/wwwlogs/laravel.log;
        location / {
                try_files $uri $uri/ /index.php$query_string;
        }
        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass  unix:/tmp/php-cgi-70.sock;
                try_files $uri =404;
                fastcgi_index   index.php;
                fastcgi_param SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        }
}


lnmp宝塔
server
{
    listen 80;
    server_name 140.82.0.240;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/aaa/public;


    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #SSL-END


    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    error_page 404 /404.html;
    error_page 502 /502.html;
    #ERROR-PAGE-END


    #PHP-INFO-START  PHP引用配置,可以注释或修改
    include enable-php-70.conf;
    #PHP-INFO-END


    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/140.82.0.240.conf;
    #REWRITE-END


    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    location / {
        try_files $uri $uri/ /index.php$query_string;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        access_log off;
    }


    location ~ .*\.(js|css)?$
    {
        expires      12h;
        access_log off;
    }
    access_log  /www/wwwlogs/140.82.0.240.log;
    error_log  /www/wwwlogs/140.82.0.240.error.log;
}


lnmp宝塔引入的解析


include /www/server/nginx/conf/enable-php-70.conf
location ~ [^/]\.php(/|$)
{
    try_files $uri =404;
    fastcgi_pass  unix:/tmp/php-cgi-70.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    include pathinfo.conf;
}


include fastcgi.conf;的内容
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;


fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;


fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;


fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;


include pathinfo.conf;
set $real_script_name $fastcgi_script_name;
                fastcgi_pass unix:/tmp/php-cgi-70.sock;
                set $real_script_name $1;
                set $path_info $2;
 }
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;

猜你喜欢

转载自blog.csdn.net/feiwutudou/article/details/80048660