centos装php
mkdir -p /lnmp/php74
wget https://www.php.net/distributions/php-7.4.33.tar.gz
tar -zxvf php-7.4.33
cd ./php-7.4.33
./configure --prefix=/lnmp/php74 --enable-fpm --with-mysqli --with-curl --with-pdo_mysql --with-pdo_sqlite --enable-mysqlnd --enable-mbstring --with-gd --with-freetype
(7.4之前的版本freetype是 --with-freetype-dir )
make
make install
cp php.ini-development /lnmp/php74/lib/php.ini
cd /lnmp/php74/etc
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf
cd /lnmp/php71/etc/php-fpm.d
vim www.conf
cgi.fix_pathinfo=0
/lnmp/php71/sbin/php-fpm
ps aux|grep php
vim /etc/init.d/php71-fpm
chmod a+x /etc/init.d/php71-fpm
chkconfig --add php71-fpm
service php71-fpm start
service php71-fpm restar
service php71-fpm stop
‘贰’ CentOS安装两个版本的PHP方法
刚卜棚改在阿里云配置云主机,系统是CentOS,刚配置好了PHP7.2,朋和中友的站点上传型判上来,运行行情提示:[error] 1522#0: *150 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime(),需要PHP5.X,这时想到php-fpm多监听一个端口,是不是可以实现多版本PHP运行,网上一搜果然真有,便动手干起来
最后再加一个开机启动启动
具体文章 https://blog.csdn.net/it0_soft/article/details/88716639
‘叁’ centos 如何安装最新php
一般服务器都加装防火墙,所以第一步要暂停防火墙,否则连接不到相关外网和程序源
Centos 6.默认下没有安装php组件,因此我们需要输入命令:yum -y install php 回车如下图。
不用管,程序会自动完成安装及配置。
Zend组件,Centos 6.3 里面是没有的,需要手动下载,及安装教程请点击下面链接:http://www.juxiwang.com/read-tid-2982.html
到此前期的准备工作已完成,下面就要对Apache进行配置
输入命令:vi /etc/httpd/conf/httpd.conf //打开Apache配置文件,
找到ServerTokens OS将“OS”改为“Prod “ 。//显示服务器运行错误信息。与下图一样,那么Apache你就配置成功了,如果不一样请仔细对比上面的教程是不是那个步骤少了#及字母拼写错了。
到此php运行环境便配置成功啦。
启动http, /etc/rc.d/init.d/httpd start
输入命令:vi /var/www/html/test.php 在弹出的对话框里输入信息:<?phpphpinfo();?>保存退出。然后通过你的浏览器输入:http://127.0.0.1/test.php如出现下图界面,恭喜里php运行环境你配置成功啦。
有时由于httpd.conf没有正确配置,本想浏览php文件,实际是下载了php文件,这个是因为系统没有识别php文件,所以就认为你要下载了。
修改方法: 检查你的httpd.conf当中是否有以下几行LoadMole php5_mole d:\php5\php5_apache2.dll (windows系统)
或LoadMole php5_mole /usr/libexec/apache2/php5.so(或者是libphp5.so)(linux系统)||||||根据你的平台而定,实际路径也因环境而异增加AddType application/x-httpd-php .php|||||||增加DirectoryIndex index.php index.html。一定可以ok
另,如果遇到启动httpd时出现报错信息,httpd: apr_sockaddr_info_get() failed for shiweihttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName,原因是没有设定ServerName
解决办法:
1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80
(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)
还有可能遇到的问题,linux系统里存在多个httpd.conf文件,你不知道是哪个在起作用,那么service httpd restart 启动后,用ps -ef|more看http用的是什么进程,如果是、usr/sbin就用/usr/sbin/httpd -S命令,如果是/usr/local/apache2/bin/httpd,就用/usr/local/apache2/bin/httpd -S。看是启动了哪个,httpd。conf文件启动时是唯一的。
‘肆’ 怎样在centos上安装php
开始都只需要打些代码
1.
安装Apahce, PHP, MySQL以及php连接mysql库组件。 #yum -y install httpd php mysql
mysql-server php-mysql 2. 安装apache扩展 #yum -y install httpd-manual
mod_ssl mod_perl mod_auth_mysql 3. 安装php的扩展 #yum -y install
php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc 4.
安装MySQL的扩展 #yum -y install mysql-connector-odbc mysql-devel
libdbi-dbd-mysql
2
上面的每个命令敲完后需要等待一段时间让其下载安装
#/sbin/service httpd start [启动httpd服务,与开机启动无关] #/sbin/service mysqld start [启动mysqld服务,与开机启动无关]
安装完后通过这两个命令启动服务
3
服务启动后,默认php文件存放的目录在/var/www/html目录下,这里建立一个test.php文件,里面打上些内容,如图,我这里是先删除原有的test.php,再新建
4
在浏览器中浏览
‘伍’ 如何在centos上安装php
.1 安装Apahce, PHP, MySQL以及php连接mysql库组件。 #yum -y install httpd php mysql mysql-server php-mysql 2. 安装apache扩展 #yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql 3. 安装php的扩展 #yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc 4. 安装MySQL的扩展 #yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
遇到类似的问题,你可以去后盾人平台看看的哦,里面的东西不错应该能帮你解决一些不明白的问题(❁´◡`❁)*
‘陆’ Centos7下PHP7最新版怎么安装
步骤 1:检查已安装的内核版本 # uname -sr 步骤 2:在 CentOS 7 中升级内核 接下来,安装最新的主线稳定内核: # yum --enablerepo=elrepo-kernel install kernel-ml 最后,重启机器并应用最新内核,接着运行下面的命令检查最新内核版本还有一些代码我不想打了,楼主就自己去后盾人看看吧对你很有帮助的
‘柒’ 阿里云上的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 https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
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 [email protected]
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 Molescore 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_mpio 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 安装成功!
‘捌’ 如何在centos中搭建php环境
方便一点的话你可以安装继承环境,例如phpstudy for linux
执行代码:
//1、下载phpstudy
wget-chttp://lamp.phpstudy.NET/phpstudy.bin
//2、设置权限
chmod+xphpstudy.bin
//3、运行安装
./phpstudy.bin
根据提示安装你想要的版本,安装时间大概20-30分钟左右,
安装完后直接启动
‘玖’ 如何在centos7上安装php
您好,安装PHP的方式可以一步一步的按照教程去安装,这个可以到网上搜一搜,因为步骤太多,我就不复制粘贴了。但是我这里最推荐的就是使用phpstudy一键安装,没错,就是在Linux上一键安装,可以去试一试。
黑马程序员的PHP是国内最早开设的真正人工智能课程。课程全面系统,紧跟时代潮流。
‘拾’ 如何在 CentOS 7 / Ubuntu 15.04 上安装 PHP 框架 Laravel
CentOS-7 #yum install epel-release # rpm -Uvh dl/pub/epel/epel-release-latest-7/yum/el7/webtatic-release/installer php #mv composer/laravel/laravel/archive/develop.zip 运行以下呼吁解压安装包而且移动 document 的根目录。 # unzip develop.zip #mv laravel-develop /var/www/ 此刻操作 compose 呼吁来安装目录下所有 Laravel 所需要的依赖。 #cd/var/www/laravel-develop/ # composer install compose laravel 6) 密钥 为了加密服﹏务器,我们操作以下呼吁来生成一个加密后的 32 位的密钥。 # php artisan key:generate Application key []set successfully 此刻把这个密钥放到 'app.php' 文件,如以下所示。 #vim/var/www/laravel-develop/config/app.php Key encryption 7) 虚拟主_机和所属用户 在 composer 安装好后,分派 document 根目录的权限和所属用户,如下所示。 #chmod775/var/www/laravel-develop/app/storage #chown-R apache:apache /var/www/laravel-develop 用任意一款编辑器打开 apache 服﹏务器的默认配置文件,在文件最后加上虚拟主_机配置。 #vim/etc/httpd/conf/httpd.conf ServerName laravel-develop DocumentRoot/var/www/laravel/public start Directory/var/www/laravel AllowOverrideAll Directory close 此刻我们用以下呼吁重启 apache 服﹏务器,打开浏览器检察 localhost 页面。 CentOS #systemctl restart httpd Ubuntu # service apache2 restart 8) Laravel 5 网络会见 打开浏览器然后输入你配置的 IP 地点或者完整域名(Fully qualified domain name)你将会看到 Laravel 5 的默认页面。 Laravel Default