您当前的位置:首页 > 互联网教程

服务器如何部署php

发布时间:2025-05-24 17:55:36    发布人:远客网络

服务器如何部署php

一、服务器如何部署php

1、首先是下载PHP安装文件和MYSQL安装文件,请注意MYSQL有很多个版本,有社区版、标准版、企业版、集群版,其中只有社区版是免费的。

2、在服务器上配置好IIS,推荐IIS7以上版本,控制面板-打开或关闭windows功能-万维网服务-应用程序开发功能里选上对应就可安装。

3、配置php环境:把php压缩包解压到C:\php目录下面,然后找到php.ini-dist,更名为php.ini,

把以下扩展前面的分号去掉以启用

默认为0,如果使用IIS,需要开启

默认开启,如果使用IIS,可以将其关闭

其次指定extension_dir目录和date.timezone,即

4、然后把extension=php_mysql.dll前面的分号去掉,保存并把php.ini复制到系统Windows目录下面。

5、然后依次打开我的电脑(右键)->管理->服务和应用程序->Internet信息服务(IIS)管理器,打开ISAPI和CGI限制,然后添加php的ISAPI的执行文件php5isapi.dll.

6、配置Mysql:把下载的mysql文件直接安装即可,然后复制php目录下面的libmysql.dll到系统Windows下面的System32目录里。

如果是php5.3及以上版本,根本没有php5isapi.dll,也不需要把php.ini移动到windows安装目录,建议采用安装版,直接安装即可。

二、php程序怎么部署运行

1、PHP,是英文超级文本预处理语言Hypertext Preprocessor的缩写。PHP是一种 HTML内嵌式的语言,是一种在服务器端执行的嵌入HTML文档的脚本语言。

2、所以我们想要运行PHP程序的前提就是要安装web服务器,最佳选择是Apache(IIS也能够解析PHP)。除了web服务器之外,还要安装数据库服务和最重要的php!整个配置流程很麻烦,可以用一些集成环境如phpstudy、wamp、phpnow等。但是对于初学者,我推荐自己配置环境!有助于对B/S的理解,对深入的学习php有很大的好处!具体的教程网上有很多。

3、希望我的回答对您有所帮助……呵呵

三、Thinkphp5项目在nginx服务器部署

1,切换到nginx的配置目录,找到nginx.conf文件

    cd /usr/local/nginx/conf

   vim nginx.conf

2,如果是单项目部署的话,只需要在nginx.conf文件里面加上以下

        listen 80;

        #域名,本地测试可以使用127.0.0.1或localhost

        server_name www.zhangc.cn;

        # php项目根目录

        root/home/data-www/blog;

        location/{

                #定义首页索引文件的名称

                index index.php index.html index.htm;

               #影藏入口文件

               if(-f$request_filename/index.html){

                            rewrite(.*)$1/index.html break;

                }

                if(-f$request_filename/index.php){

                            rewrite(.*)$1/index.php;

                }

                if(!-f$request_filename){

                            rewrite(.*)/index.php;

                }

                try_files$uri$uri//index.php?$query_string;

        }

        # PHP脚本请求全部转发到 FastCGI处理.使用FastCGI协议默认配置.

        # Fastcgi服务器和程序(PHP)沟通的协议

        .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;

               fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                set$path_info$fastcgi_path_info;

                fastcgi_param PATH_INFO$path_info;

                try_files$fastcgi_script_name=404;

        }

3,如果多项目部署,就需要配置vhost

第一步:编辑nginx.conf文件,在最后加上   include  vhost/*.conf;

第二步:进入vhost文件夹,创建  域名.conf  文件,如创建一个:quanma.meyat.com.conf

第三步:编辑quanma.meyat.com.conf文件,内容如下:

        server

        {

                listen 80;

                server_name quanma.meyat.com;

         index index.html index.htm index.php default.html default.htm default.php;

                root/data/wwwroot/default/quanma/public/;

                #error_page 404/404.html;

                location/{

                        index index.html index.php;

                        if(-f$request_filename/index.html){

                                rewrite(.*)$1/index.html break;

                        }

                        if(-f$request_filename/index.php){

                                rewrite(.*)$1/index.php;

                        }

                        if(!-f$request_filename){

                                rewrite(.*)/index.php;

                        }

                        try_files$uri$uri//index.php?$query_string;

                }

                location~ [^/]\.php(/|$)

                {

                        # comment try_files$uri=404; to enable pathinfo

                        #try_files$uri=404;

                        fastcgi_pass 127.0.0.1:9000;

                        fastcgi_index index.php;

                        include fastcgi_params;

                        fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;

                        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                        set$path_info$fastcgi_path_info;

                        fastcgi_param PATH_INFO$path_info;

                        try_files$fastcgi_script_name=404;

                        #include fastcgi.conf;

                        #include pathinfo.conf;

            }

            location~.*\.(gif|jpg|jpeg|png|bmp|swf)$

            {

                    expires 30d;

            }

            location~.*\.(js|css)?$

            {

                    expires 12h;

            }

            # Disallow access to.ht,.svn,.bzr,.git,.hg,.cvs directories

            location~/\.(ht|svn|bzr|git|hg|cvs){

                    deny all;

            }

            #access_log/date/nginx/bmp.com.conf/access.log main;