⑴ 如何在ftp服务器上部署php网站
首先你的服务器上要有一个能解析PHP的软件,如:APACHE,TOMCAT等等,先启动这个软件,具体的配置方法可以上网再找一下。然后在他们的配置文件中,把你的这个PHP文件夹设置为网站的发布位置,这样你就能通过IP地址网络来访问了。如果想通过域名的方式来访问,那就比较复杂了,首先得有个域名,然后还需要有DNS解析服务器来解释这个域名具体指向的位置。然后才能通过域名来访问你的网站。
⑵ 服务器如何部署php
是php5.3以下版本的安装方法。
1、首先是下载PHP安装文件和MYSQL安装文件,请注意MYSQL有很多个版本,有社区版、标准版、企业版、集群版,其中只有社区版是免费的。
2、在服务器上配置好IIS,推荐IIS7以上版本,控制面板-打开或关闭windows功能-万维网服务-应用程序开发功能里选上对应就可安装。
3、配置php环境:把php压缩包解压到C:php目录下面,然后找到php.ini-dist,更名为php.ini,
修改里面的扩展目录
extension_dir
=
“C:phpext”。
把以下扩展前面的分号去掉以启用
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
fastcgi.impersonate=1
默认为0,如果使用IIS,需要开启
cgi.fix_pathinfo=1
cgi.force_redirect=0
默认开启,如果使用IIS,可以将其关闭
其次指定extension_dir目录和date.timezone,即
extension_dir =
"C:/php53iis/ext"
date.timezone=
Asia/Shanghai
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目录里。
7、重启IIS,即完工。
如果是php5.3及以上版本,根本没有php5isapi.dll,也不需要把php.ini移动到windows安装目录,建议采用安装版,直接安装即可。
⑶ php网站怎么传到云服务器
要将网站上传到服务器上,方法有多种。上传时可以按网站目录传也可以打包成一个zip或
rar文件一次传。
可选择的方法有:
(1)FTP方式。如果你的网站上安装有FTP服务器(比如IIS上就有FTP服务器),可以使用文件夹地址栏中输入ftp://你的服务器ip的方式(或使用ftp客户端软件)连接上去,然后选择php网站文件上传即可。
(2)既然使用云服务器,应该可以通过远程桌面程序登录。那么可以按如图所示操作:
第一步,打开“远程桌面连接”程序(点击“开始”->“所有程序”->“附件”->“远程桌面连接”);
第二步,如上图显示,点击“本地资源”选项卡;
第三步,在选项卡中,点击本地设备和资源中的“详细信息”,弹出一个对话框;
第四步,在对话框中找到“驱动器”,点击左边的+号,就会在下面列出如图上所示的你的电脑上的分区(图片中是我电脑上的),选择你php网站所在的那个盘打个勾;
第五步,确定关闭对话框后,开始连接。
这样和原来一样连接远程服务器后,就能在云服务器的“我的电脑”中看到你本地电脑上刚勾选的那个盘了,然后在服务器上就能像操作你电脑一样,将文件从服务器复制粘贴到你的电脑上或从你的电脑上复制粘贴到服务器上了。
⑷ Thinkphp5项目在nginx服务器部署
1,切换到nginx的配置目录,找到nginx.conf文件
cd /usr/local/nginx/conf
vim nginx.conf
2,如果是单项目部署的话,只需要在nginx.conf文件里面加上以下
server{
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;
}
⑸ 怎么在linux服务器上配置php环境
建议多使用网络搜索,网上这样的帖子特别多。
Linux的分支比较大,不过常使用的也就Centos和Ubuntu。下面我贴出来在Centos上面搭建php环境的方法,命令有所不同,不过差异不大。
安装apache:
yum install httpd httpd-devel
启动apache:
/etc/init.d/httpd start
此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口
安装mysql:
yum install mysql mysql-server
启动mysql:
/etc/init.d/mysqld start
安装php
yum install php php-devel
重启apache使php生效
/etc/init.d/httpd restart
此时可以在目录:/var/www/html/下建立一个PHP文件
代码:
<?php phpinfo(); ?>
然后访问这个文件,就能看到PHP的一些信息,php.ini配置文件的路径可以在这个页面上看到
安装php的扩展
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装完扩展之后需要再次重启apache
/etc/init.d/httpd restart
测试mysql是否链接成功的php代码
<?php
$con = mysql_connect("10.0.@.@@","@@","@@");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT * FROM sys_user");
while($row = mysql_fetch_array($result))
{
echo $row['UserName'] . " " . $row['PassWord'] . " " . $row['id'];
echo "<br />";
}
mysql_close($con);
?>
可以把上面的代码传入目录/var/www/html/
就可以看到执行情况