lnmp 总是下载index.php问题

 

 

1.配置nginx.conf文件

 location ~ \.php(.*)$ {
	        fastcgi_pass  unix:/tmp/php-cgi.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;
        }

2.配置绑定网站目录配置文件 www.test.com.conf

 listen 127.0.0.1:9000;
        #listen [::]:80;
 server_name www.cygfast.club cygfast.club;
 index.html index.htm index.php default.html default.htm default.php;
 root  /data/www/blog/public;

 include rewrite/other.conf;
 include enable-php-pathinfo.conf;

3.检查enable-php.conf配置文件

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

4.检查fastcgi.conf配置文件

# fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

该配置注销之后修改为

fastcgi_param PHP_ADMIN_VALUE "open_basedir=/data/www/:/tmp/:/proc/";

/data/www为你的项目目录,为了解决访问index.php报出来的错误 ,错误如下图所示

5.出现错误的时候可以在index.php文件里加入如下代码 ,查看什么错误

error_reporting(E_ALL); ini_set('display_errors', '1');

 

好的,以下是使用Dockerfile搭建LNMP环境的步骤: 1. 编写Dockerfile文件 在一个空的目录中创建一个名为Dockerfile的文件,并在其中输入以下内容: ```Dockerfile # 指定基础镜像 FROM ubuntu:18.04 # 更新软件源 RUN apt-get update # 安装 nginx RUN apt-get install -y nginx # 安装 PHP RUN apt-get install -y php-fpm php-mysql # 安装 MySQL RUN apt-get install -y mysql-server # 将配置文件复制到容器内 COPY nginx.conf /etc/nginx/nginx.conf COPY index.php /var/www/html/index.php # 暴露端口 EXPOSE 80 # 启动 nginxphp-fpm 服务 CMD service nginx start && service php7.2-fpm start && tail -f /var/log/nginx/access.log ``` 2. 创建Nginx的配置文件 在同一目录下创建一个名为nginx.conf的文件,并在其中输入以下内容: ```conf user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE # ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 80; server_name localhost; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } ``` 3. 创建PHP文件 在同一目录下创建一个名为index.php的文件,并在其中输入以下内容: ```php <?php phpinfo(); ?> ``` 4. 构建Docker镜像 在终端中进入到该目录,然后执行以下命令来构建Docker镜像: ```bash docker build -t lnmp . ``` 5. 运行Docker容器 执行以下命令来运行Docker容器: ```bash docker run -d --name lnmp -p 80:80 lnmp ``` 在运行容器之后,您可以在浏览器中输入http://localhost 来访问LNMP环境,其中172.10.1.2为nginx,172.10.0.3为PHP,172.10.0.4为MySQL。 希望这些步骤对您有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值