设为首页 加入收藏

TOP

LNMP简介(四)
2023-07-23 13:35:50 】 浏览:79
Tags:LNMP 简介
-fpm \ --enable-mysqlnd \ --with-mysqli \ --with-pdo-mysql \ --enable-opcache \ --with-pcre-jit \ --enable-gd \ --with-jpeg \ --with-freetype \ --with-gettext \ --with-curl \ --with-openssl \ --enable-sockets \ --enable-mbstring \ --enable-xml \ --with-zip \ --with-zlib \ --with-snmp \ --with-mhash \ --enable-ftp \ --enable-bcmath \ --enable-soap \ --enable-shmop \ --enable-sysvsem \ --enable-pcntl \ --with-gmp //显示这个表示没问题了 +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. [root@php php-8.1.11]# make && make install //配置环境变量 [root@php ~]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php8.sh [root@php ~]# source /etc/profile.d/php8.sh //配置php-fpm [root@php ~]# cd php-8.1.11 [root@php php-8.1.11]# cp php.ini-production /etc/php.ini cp: overwrite '/etc/php.ini'? y [root@php php-8.1.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@php php-8.1.11]# chmod +x /etc/rc.d/init.d/php-fpm [root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf [root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf //启动php-fpm [root@php ~]# service php-fpm start Starting php-fpm done [root@php ~]# ss -anlt State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:9000 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:*

安装后配置

php端配置

//修改配置文件
[root@php ~]# vim /usr/local/php8/etc/php-fpm.d/www.conf
listen = 192.168.111.143:9000		//修改为php本机IP

listen.allowed_clients = 192.168.111.141	//允许指定ip访问

//在php端上配置网站
[root@php ~]# mkdir -p /var/www/html
[root@php ~]# vim /var/www/html/index.php
<?php
    phpinfo();
?>

//重启php-fpm服务
[root@php ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@php ~]# ss -anlt
State        Recv-Q       Send-Q               Local Address:Port               Peer Address:Port       Process       
LISTEN       0            128                        0.0.0.0:22                      0.0.0.0:*                        
LISTEN       0            128                192.168.111.143:9000                    0.0.0.0:*                        
LISTEN       0            128                           [::]:22                         [::]:*                        

nginx服务器端

//创建一个.php结尾的文件,用于匹配
[root@nginx ~]# touch /usr/local/nginx/html/index.php

//修改配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
#查找index
        location / {
            root   html;
            index  index.php index.html index.htm;		//添加index.php
        }
        
#大概65-71行,取消注释
 location ~ \.php$ {
            root           /var/www/html;			//指向php端index.php文件位置
            fastcgi_pass   192.168.111.143:9000;	//ip地址为php服务器地址
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;		//将/scripts更改为$document_root
            include        fastcgi_params;
        }


//重启服务
[root@nginx ~]# systemctl restart nginx

浏览器访问

image

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇深入理解计算机系统-第3章程序的.. 下一篇KVM导入Ubuntu/Centos Cloud Imag..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目