當前位置:首頁 » 編程語言 » centos裝php

centos裝php

發布時間: 2023-06-01 10:26:52

『壹』 linux 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

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:333
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:374
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:609
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:30
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:105
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:940
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:736
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:800
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:507
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:369