centos php网站部署,php网站部署教程
今天给各位分享centos php网站部署的知识,其中也会对php网站部署教程进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
阿里云上的centos 7.2怎么yum安装php 5.6
因之前通过网易的 centos镜像,将阿里云的 centos升级到最新版了,乘自己的项目尚未开始正式开发,遂将所有的相应环境都升级到最高。
查看 centos版本:
[root@iZ23d~]# cat/etc/centos-release
CentOS Linux release 7.2.1511(Core)
1、删除之前的 php版本:
[root@iZ23d~]# yum remove php* php-common
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: php-5.4.16
No Match for argument: php-5.4.16.tar.gz
No Match for argument: php-7.0.1RC1
No Match for argument: php-7.0.1RC1.tar.gz
No Match for argument: phpMyAdmin-4.4.0.tar.gz
No Match for argument: php-common
No Packages marked for removal
2、rpm安装 Php7相应的 yum源:
[root@iZ23d~]# rpm-Uvh
Retrieving
warning:/var/tmp/rpm-tmp.LhJKKR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...################################# [100%]
package webtatic-release-7-3.noarch is already installed
3、直接yum安装php7:
[root@iZ23d~]# yum install php70w
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
。。。【省略】
Warning: RPMDB altered outside of yum.
Installing: php70w-common-7.0.0-1.w7.x86_64 1/3
Installing: php70w-cli-7.0.0-1.w7.x86_64 2/3
Installing: php70w-7.0.0-1.w7.x86_64 3/3
Verifying: php70w-7.0.0-1.w7.x86_64 1/3
Verifying: php70w-common-7.0.0-1.w7.x86_64 2/3
Verifying: php70w-cli-7.0.0-1.w7.x86_64 3/3
Installed:
php70w.x86_64 0:7.0.0-1.w7
Dependency Installed:
php70w-cli.x86_64 0:7.0.0-1.w7 php70w-common.x86_64 0:7.0.0-1.w7
Complete!
4、检查 php版本:
[root@iZ23d~]# php-v
PHP 7.0.0(cli)(built: Dec 2 2015 20:42:32)( NTS)
Copyright(c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright(c) 1998-2015 Zend Technologies
[root@iZ23d2e6hoqZ~]#
以上显示安装成功!
5、重启 Apache,查看 phpinfo:
[root@iZ23d~]# systemctl restart httpd.service
检查phpinfo:
PHP Version 7.0.0
SystemLinux iZ23d 3.10.0-229.11.1.el7.x86_64#1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64
Build DateDec 2 2015 20:43:38
Server APIApache 2.0 Handler
Virtual Directory Supportdisabled
Configuration File(php.ini) Path/etc
Loaded Configuration File/etc/php.ini
Scan this dir for additional.ini files/etc/php.d
Additional.ini files parsed/etc/php.d/bz2.ini,/etc/php.d/calendar.ini,/etc/php.d/ctype.ini,/etc/php.d/curl.ini,/etc/php.d/exif.ini,/etc/php.d/fileinfo.ini,/etc/php.d/ftp.ini,/etc/php.d/gettext.ini,/etc/php.d/gmp.ini,/etc/php.d/iconv.ini,/etc/php.d/json.ini,/etc/php.d/phar.ini,/etc/php.d/shmop.ini,/etc/php.d/simplexml.ini,/etc/php.d/sockets.ini,/etc/php.d/tokenizer.ini,/etc/php.d/xml.ini,/etc/php.d/zip.ini
PHP API20151012
PHP Extension20151012
Zend Extension320151012
Zend Extension BuildAPI320151012,NTS
PHP Extension BuildAPI20151012,NTS
Debug Buildno
Thread Safetydisabled
Zend Signal Handlingdisabled
Zend Memory Managerenabled
Zend Multibyte Supportdisabled
IPv6 Supportenabled
DTrace Supportenabled
Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filterszlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.0.0, Copyright(c) 1998-2015 Zend Technologies
Configuration
apache2handler
Apache VersionApache/2.4.6(CentOS)
Apache API Version20120211
Server Administratorxxxxxx@xxxxxx.com
Hostname:Portxxxx.xxxxx.xxx:0
User/Groupapache(48)/48
Max RequestsPer Child: 0- Keep Alive: on- Max Per Connection: 100
TimeoutsConnection: 60- Keep-Alive: 15
Virtual ServerYes
Server Root/etc/httpd
Loaded Modulescore mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_dumpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_wstunnel mod_ssl mod_systemd mod_cgi mod_perl mod_php7
以上显示 php7安装成功!
php项目怎么部署到服务器(php项目怎么部署到服务器中)
使用php开发的项目必须部署在才能正常运行
使用PHP开发的项目必须部署在Web服务器上才能正常运行。PHP是一种服务器端脚本语言,用于开发动态网站和Web应用程序。PHP脚本必须在Web服务器上运行,才能被解释和执行。因此,使用PHP开发的项目必须部署在Web服务器上才能正常运行。在部署PHP项目时,需要将PHP脚本文件和相关的资源文件上传到Web服务器上,并配置好Web服务器的环境和参数,以确保PHP脚本能够被正确解释和执行。常用的Web服务器包括Apache、Nginx等,可以根据具体需求选择合适的Web服务器进行部署。需要注意的是,部署PHP项目时需要考虑安全性和性能等因素,以确保项目的稳定性和可靠性。
php项目如何部署??
首先是要对数据结构进行规划,然后根据项目大小决定是否用php框架或模板技术,之后就是后台功能开发,最后再把数据在前台展示出来;这只是基本步骤,真正实施起来,涉及的东西是很多的,要注意的细节也很多
Thinkphp5项目在nginx服务器部署
1,切换到nginx的配置目录,找到nginx.conf文件
????cd?/usr/local/nginx/conf
??vim?nginx.conf
2,如果是单项目部署的话,只需要在nginx.conf文件里面加上以下
server{
????????listen80;
????????#域名,本地测试可以使用127.0.0.1或localhost
????????server_name;
????????#php项目根目录
????????root/home/data-www/blog;
????????location/{
????????????????#定义首页索引文件的名称
????????????????indexindex.phpindex.htmlindex.htm;
???????????????#影藏入口文件
???????????????if(-f$request_filename/index.html){
????????????????????????????rewrite(.*)$1/index.htmlbreak;
????????????????}
????????????????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_pass127.0.0.1:9000;
????????????????#设置nginx的默认首页文件
????????????????fastcgi_indexindex.php;
????????????????#设置脚本文件请求的路径
????????????????fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
????????????????#引入fastcgi的配置文件
????????????????includefastcgi_params;
???????????????fastcgi_split_path_info^(.+?\.php)(/.*)$;
????????????????set$path_info$fastcgi_path_info;
????????????????fastcgi_paramPATH_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
????????{
????????????????listen80;
????????????????server_namequanma.meyat.com;
????????indexindex.htmlindex.htmindex.phpdefault.htmldefault.htmdefault.php;
????????????????root/data/wwwroot/default/quanma/public/;
????????????????#error_page404/404.html;
????????????????location/{
????????????????????????indexindex.htmlindex.php;
????????????????????????if(-f$request_filename/index.html){
????????????????????????????????rewrite(.*)$1/index.htmlbreak;
????????????????????????}
????????????????????????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(/|$)
????????????????{
????????????????????????#commenttry_files$uri=404;toenablepathinfo
????????????????????????#try_files$uri=404;
????????????????????????fastcgi_pass127.0.0.1:9000;
????????????????????????fastcgi_indexindex.php;
????????????????????????includefastcgi_params;
????????????????????????fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
????????????????????????fastcgi_split_path_info^(.+?\.php)(/.*)$;
????????????????????????set$path_info$fastcgi_path_info;
????????????????????????fastcgi_paramPATH_INFO$path_info;
????????????????????????try_files$fastcgi_script_name=404;
????????????????????????#includefastcgi.conf;
????????????????????????#includepathinfo.conf;
????????????}
????????????location~.*\.(gif|jpg|jpeg|png|bmp|swf)$
????????????{
????????????????????expires30d;
????????????}
????????????location~.*\.(js|css)?$
????????????{
????????????????????expires12h;
????????????}
????????????#Disallowaccessto.ht,.svn,.bzr,.git,.hg,.cvsdirectories
????????????location~/\.(ht|svn|bzr|git|hg|cvs){
????????????????????denyall;
????????????}
????????????#access_log/date/nginx/bmp.com.conf/access.logmain;
}
服务器上怎么安装php程序
你好,如果你的服务器是Windows系统,那么你需要远程到你的服务器,进行启动IIS(asp环境),如果你需要php环境,你可以从xp.cn(小皮)或者bt.cn(宝塔)安装面板
如果你的服务器是Linux,建议使用宝塔
打开终端,不同Linux系统的输入指令不同:
Centos安装脚本
终端输入:yuminstall-ywgetwget-Oinstall.shshinstall.sh
Ubuntu/Deepin安装脚本
终端输入:wget-Oinstall.shsudobashinstall.sh
Debian安装脚本
终端输入:wget-Oinstall.shbashinstall.sh
Fedora安装脚本
终端输入wget-Oinstall.shbashinstall.sh
输入后进行安装就可以了
php项目如何部署在服务器上
一、阿里ECS服务器配置
???1.因为线上已经有几个站点了.所以要配置ngnix多站点
???2.阿里云ecs目录结构,ngxin在/etc/nginx/目录下,配置的地方主要是nginx.config文件。或者在conf.d新建一个配置文件然后在include到nginx.config文件中
?????
???3.nginx.config新建站点信息
server{
listen???80;
server_name?www.你的域名.com;
root????站点的相对路径;
indexindex.phpindex.htmlindex.htm;
#charsetkoi8-r;
#access_log?/var/log/nginx/host.access.log?main;
#Loadconfigurationfilesforthedefaultserverblock.
include/etc/nginx/default.d/*.conf;
location/{
#try_files$uri$uri//index.php;
root?/opt/www/pcweb/ytyy_pc;
index?index.phpindex.htmlindex.htm;???????if(!-e$request_filename){?rewrite?^(.*)$/index.php?s=$1?last;?break;??}}??????url重写(可以没有)
#redirectservererrorpagestothestaticpage/40x.html
#
error_page?404???????/404.html;?40错误页面配置
location=/40x.html{
}
#redirectservererrorpagestothestaticpage/50x.html
#
error_page?500502503504?/50x.html;?50错误页面配置
location=/50x.html{
}
location~\.php${
root?????站点相对路径;
fastcgi_pass?127.0.0.1:9000;
fastcgi_index?index.php;
fastcgi_param?SCRIPT_FILENAME?$document_root$fastcgi_script_name;
include????fastcgi_params;
}
location~/\.ht{
deny?all;
}
}
配置文件的基本内容如上;
配置完成后测试配置文件是否正确
这样配置就可以使用了
然后重启nginx服务器?
这样nginx配置就结束了可以使用了。吧站点文件放到对应的目录下面。我直接gitclone过去的。
二.thinkphp项目文件转移
本来以为上传完就结束了。上传上去碰到的第一个问题就是访问页面报错,页面被电信的114页面劫持了。。。麻蛋看不到报错
万能百度大法
解决方法1.internet高级选项-隐私-站点??新加阻止站点
解决方法2:控制面板-网络和internet-本地连接-属性-ipv4?使用如下ip
终于搞定可以看到报错页面了。。。。。。麻蛋。再次开启万能百度大法
?
?
?得到最终结论是文件目录权限引起的。thinkphp的runtime目录没有写入权限。。thinkphp文件上传到阿里的好像都有这个问题。解决问题很简单
进入到项目文件目录
直接跟文件最高权限
chmod-R777[目录]?//linux修改文件权限
?
前端vue与后端Thinkphp在服务器的部署
vue在服务端部署时,我们都知道通过npmrunbuild指令打包好的dist文件,通过http指定是可以直接浏览的,Thinkphp通过域名指向index.php文件才可以浏览。要使前端正常调用后端数据,有两种方法:1、前端跨域调用后端数据,2、前端打包文件部署在后端的服务器文件夹下(同域)。
web服务器:apache
一、跨域
在服务器配置站点:
在路径/home/www/??下创建test项目文件夹,用来放项目文件。??
找到httpd-vhosts.conf文件配置站点??
前端站点:??
????ServerName?test.test.com??
????DocumentRoot?"/home/www/test/dist"????
????DirectoryIndex?index.html??
后端站点:??
????ServerName?test.testphp.com??
????DocumentRoot?"/home/www/test/php"????
????DirectoryIndex?index.php??
将前端打包好的dist文件放在/home/www/test/文件夹下,运行可浏览,当路径改变时,刷新会出现404错误。此时dist文件下创建一个.htaccess文件,当路径不存在时,路径指向能解决此问题。
??RewriteEngine?On??
??RewriteBase?/??
??RewriteRule?^index\.html$?-?[L]??
??RewriteCond?%{REQUEST_FILENAME}?!-f??
??RewriteCond?%{REQUEST_FILENAME}?!-d??
??RewriteRule?.?/index.html?[L]??
在/home/www/test文件夹下创建项目根目录php文件夹,将thinkphp文件放在php下。TP5的入口文件在public文件下,在这将public下的入口文件index.php挪到php文件夹下(个人习惯将入口文件放在项目根目录),后端绑定Index模块。
前端调用后端接口,存在跨域,跨域解决方法有好几种,在这我将在后端php做配置,解决跨域问题,在公用控制器设置跨域配置:
class?Common?extends?Controller??
{??
????public?$param;??
????//?设置跨域访问??
????public?function?_initialize()??
????{??
????????parent::_initialize();??
????????isset($_SERVER['HTTP_ORIGIN'])???header('Access-Control-Allow-Origin:?'.$_SERVER['HTTP_ORIGIN'])?:?'';??
????????header('Access-Control-Allow-Credentials:?true');??
????????header('Access-Control-Allow-Methods:?GET,?POST,?PUT,?DELETE,?OPTIONS');??
????????header("Access-Control-Allow-Headers:?Origin,?X-Requested-With,?Content-Type,?Accept,?authKey,?sessionId");??
$param?=??Request::instance()-param();??
$this-param?=?$param;??
????}??
}??
前端调用登录接口:this.axios.post('',{user:'',password:''})。
(可在webpack.base.conf.js文件下可定义接口:)
二、同域
后端配置同上,公共配置器中的header配置注释。将前端的dist文件下的所有文件(包含.htaccess),放在php文件夹下。将后端index控制器的index方法的路径重定向php下的index.html文件:
namespace?app\index\controller;??
use?think\Controller;??
class?Index?extends?Controller??
{??
????public?function?index()?{??
$this-redirect('/index.html');??
????}??
}??
前端调用登录接口:this.axios.post('/index.php/base/login',{user:'',password:''})
转自:
CentOS安装了PHP7.4后PHP编写的网站还是不能打开
网站打不开有多种原因。
权限不足,因为需要写入缓存文件,如果权限不足,程序无法运行。数据库未连接,基本上所有的网站都需要数据库存储信息,如果数据库连接不对,也无法访问网站。php版本不对,有些程序是特定版本下才能运行的,如果版本过高或者过低,都有可能导致程序出错,网站无法打开。
对于无法打开的网站,最好是开启服务器的日志和报错信息,这样有利于排查问题。