php检测页面的部署___保姆级

当输入以下命令的时候没有问题的时候就可以部署PHP测试页面了。

[root@localhost ~]# php -v
PHP 7.3.27 (cli) (built: Apr  1 2021 22:04:00) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
[root@localhost ~]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaf
zip
zlib

[Zend Modules]

安装Nginx

[root@localhost ~]# yum -y install nginx

启动Nginx

[root@localhost ~]# systemctl start nginx

编辑Nginx配置文件

[root@localhost conf.d]# pwd
/etc/nginx/conf.d
[root@localhost conf.d]# ls
php.conf
[root@localhost conf.d]# vim php.conf
server {
        listen 80;
        # 这里改动了,也可以写你的域名
        server_name  10.0.10.250;

        # 默认网站根目录(www目录)
        root         /var/www/;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            # 这里改动了 定义首页索引文件的名称
            index index.php index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {

        }
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
        # 这里新加的
        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.
        # Fastcgi服务器和程序(PHP,Python)沟通的协议.
        location ~ \.php$ {
            # 设置监听端口
            fastcgi_pass   127.0.0.1:9000;
            # 设置nginx的默认首页文件(上面已经设置过了,可以删除)
            fastcgi_index  index.php;
            # 设置脚本文件请求的路径
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            # 引入fastcgi的配置文件
            include        fastcgi_params;
        }
    }
[root@localhost conf.d]# nginx -t  ##检测配置文件是否有问题
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost conf.d]# nginx -s reload  ##重新加载配置文件

编辑php测试文件

[root@localhost www]# pwd
/var/www  ##目录没有就创建
[root@localhost www]# ls
index.php
[root@localhost www]# cat index.php
<?php
    phpinfo()
?>

浏览器测试
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是在Ubuntu上部署PHPThink5项目的保姆级教程: 1. 安装Web服务器、PHP和MySQL 在Ubuntu上安装Web服务器、PHP和MySQL是部署PHPThink5项目的第一步。具体的安装过程可以使用以下命令: ``` sudo apt update sudo apt install apache2 php mysql-server php-mysql ``` 安装过程中会提示你设置MySQL的root账户密码。 2. 下载PHPThink5的压缩包并解压 在Ubuntu上下载PHPThink5的压缩包并解压到你想要部署的目录中,可以使用以下命令: ``` wget https://github.com/top-think/think/archive/5.1.52.tar.gz tar -zxvf 5.1.52.tar.gz ``` 其中`https://github.com/top-think/think/archive/5.1.52.tar.gz`是PHPThink5的压缩包下载链接,可以根据自己的需要选择不同的版本。 3. 创建MySQL数据库并配置 在MySQL中创建一个新的数据库,并将数据库信息配置到`application/database.php`文件中,具体的步骤如下: - 登录MySQL: ``` sudo mysql -u root -p ``` - 创建一个新的数据库: ``` CREATE DATABASE your_database_name; ``` - 创建一个新的MySQL用户并授权: ``` CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost'; ``` - 刷新MySQL权限: ``` FLUSH PRIVILEGES; ``` - 退出MySQL: ``` exit; ``` - 将数据库信息配置到`application/database.php`文件中: ``` // 数据库类型 'type' => 'mysql', // 服务器地址 'hostname' => 'localhost', // 数据库名 'database' => 'your_database_name', // 数据库用户名 'username' => 'your_username', // 数据库密码 'password' => 'your_password', // 数据库编码默认采用utf8 'charset' => 'utf8', ``` 4. 安装Composer依赖 在终端中切换到PHPThink5目录下,运行以下命令安装Composer依赖: ``` cd think-5.1.52 sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" sudo php composer-setup.php sudo php -r "unlink('composer-setup.php');" sudo php composer.phar install ``` 这个过程可能需要一些时间,取决于你的网络速度和计算机性能。 5. 生成应用目录 运行以下命令生成应用目录: ``` php think build ``` 这个命令会在当前目录下生成一个`runtime`目录和一个`application`目录。其中`application`目录是你的应用程序目录,`runtime`目录是PHPThink5的运行时目录。 6. 配置Web服务器 配置Web服务器,使其指向PHPThink5的`public`目录。具体的配置方式取决于你使用的Web服务器,下面以Apache为例: - 打开Apache的配置文件: ``` sudo nano /etc/apache2/sites-available/000-default.conf ``` - 在`VirtualHost`标签中添加以下内容: ``` DocumentRoot /path/to/think-5.1.52/public <Directory /path/to/think-5.1.52/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ``` 其中`/path/to/think-5.1.52`是你解压PHPThink5的目录。 - 重启Apache: ``` sudo systemctl restart apache2 ``` 7. 访问应用程序 访问你的Web服务器,应该能够看到PHPThink5的欢迎界面。如果你使用的是Apache Web服务器,在浏览器中输入以下URL: ``` http://your_server_ip/ ``` 其中`your_server_ip`是你的服务器IP地址。 注意事项: - 在部署之前,确保你已经正确地配置了Web服务器、PHP和MySQL,否则你的应用无法正常运行; - 在部署之前,建议先在本地环境中测试你的应用,确保没有问题再进行部署; - 在部署之后,建议关闭调试模式,以提高应用的安全性和性能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值