當前位置:首頁 » 編程語言 » centos7安裝php56

centos7安裝php56

發布時間: 2022-08-23 05:54:12

Ⅰ CentOS7 安裝php提示如下錯誤

你可以使用下面的方法

首先配置yum源

#yuminstallepel-release
#rpm-ivhhttp://rpms.famillecollet.com/enterprise/remi-release-7.rpm

使用yum list命令查看可安裝的包(Packege)。

#yumlist--enablerepo=remi--enablerepo=remi-php56|grepphp

安裝PHP5.6

yum源配置好了,下一步就安裝PHP5.6。

#yuminstall--enablerepo=remi--enablerepo=remi-php56phpphp-opcachephp-develphp-mbstringphp-mcryptphp-mysqlndphp-phpunit-PHPUnitphp-pecl-xdebugphp-pecl-xhprof

用PHP命令查看版本。

#php--version

linux centos 7 下用yum 安裝iso鏡像里自帶的php5.4.16版本的但是沒有php-fqm文件不知道怎麼重啟php服務

systemctl restart php-fpm.service #這條命令是重啟php服務
下面是一個比較靠譜的php安裝步驟:
先刪除已有的php版本 ,執行下面的命令刪除php
yum remove php-common
然後像安裝那樣問你是否繼續的,輸入yes即可

添加 yum 源
CentOS 6.x 的源
# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

安裝 PHP
# yum install --enablerepo=remi,remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
註:安裝5.6版本為remi-php56,安裝5.5版本為remi-php55

Ⅲ 怎麼在centos 7上安裝php環境

http://jingyan..com/article/9f63fb91a6aaa2c8400f0ec8.html
-供參考

Ⅳ 怎麼安裝PHP環境

LAMP/LNMP 環境搭建

一.檢查系統環境

1.確認centos版本

[root@localhost ~]# cat /etc/redhat-release

2.檢查是否安裝過apache

rpm -qa | grep httpd

或者:

apachectl -v

或者:

httpd -v

3.檢查是否安裝過Mysql

service mysqld start

如果未被識別則沒有安裝

如果系統安裝過,或者安裝失敗,清理一下系統

4.清理Mysql痕跡

yum remove mysql

rm -f /etc/my.cnf

5.卸載Apache包

rpm -qa|grep httpd

注意:如果是新的系統或者你從來沒有嘗試安裝過,則以上步驟省略

二.安裝Apache、PHP、Mysql

停止防火牆服務

[root@localhost ~]# systemctl stop firewalld.service

禁用防火牆開機啟動服務

[root@localhost ~]# systemctl disable firewalld.service

1.安裝apache

[root@localhost ~]# yum -y install httpd

2.安裝php

[root@localhost ~]# yum -y install php

3.安裝php-fpm

[root@localhost ~]# yum -y install php-fpm

4.安裝Mysql

[root@localhost ~]# yum -y install mysql

5.安裝 mysql-server

[root@localhost ~]# yum install mariadb-server

CentOS 7+ 版本將MySQL資料庫軟體從默認的程序列表中移除,用mariadb代替了,entos7配置教程上,大多都是安裝mariadb,因為centos7默認將mariadb視作mysql。

因為mysql被oracle收購後,原作者擔心mysql閉源,所以又寫了一個mariadb,這個資料庫可以理解為mysql的分支。如果需要安裝mariadb,只需通過yum就可。

6.安裝 php-mysql

[root@localhost ~]# yum -y install php-mysql

三.安裝基本常用擴展包

1.安裝Apache擴展包

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

2.安裝PHP擴展包

yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel

3.安裝Mysql擴展包

yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

四.配置Apache、mysql開機啟動

重啟Apache、mysql服務(注意這里和centos6有區別,Cenots7+不能使用6的方式)

systemctl start httpd.service #啟動apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重啟apache

systemctl enable httpd.service #設置apache開機啟動

重啟資料庫

#啟動MariaDB

[root@localhost ~]# systemctl start mariadb.service

#停止MariaDB

[root@localhost ~]# systemctl stop mariadb.service

#重啟MariaDB

[root@localhost ~]# systemctl restart mariadb.service

#設置開機啟動

[root@localhost ~]# systemctl enable mariadb.service

五.配置Mysql

初次安裝mysql是沒有密碼的,我們要設置密碼,mysql的默認賬戶為root

方式1:設置 MySQL 數據 root 賬戶的密碼:

[root@localhost ~]# mysql_secure_installation

當出現如下提示時候直接按回車:

Enter current password for root

出現如下再次回車:

Set root password? [Y/n]

出現如下提示輸入你需要設置的密碼,這里輸入了root,輸入密碼是不顯示的,回車後再輸入一次確認:

New password:

接下來還會有四個確認,分別是:

Remove anonymous users? [Y/n]

Disallow root login remotely? [Y/n]

Remove test database and access to it? [Y/n]

Reload privilege tables now? [Y/n]

直接回車即可。

方式2:進入mysql mysql -r

修改mysql密碼:set password for 'root'@'localhost'=password('root');

mysql授權遠程連接(navicat等): grant all on *.* to root identified by 'root';

六.測試環境

我們在瀏覽器地址欄輸入http://ip/,正常顯示,說明我們的lamp 環境搭建成功

七.安裝nginx

yum install yum-priorities -y

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install nginx

Nginx 版本號可變更http://nginx.org/packages/centos/7/noarch/RPMS/$版本

八.配置nginx

1.nginx啟動,停止,重啟

systemctl start nginx.service #啟動nginx

systemctl stop nginx.service #停止

systemctl restart nginx.service #重啟

systemctl enable nginx.service #設置開機啟動

  • 更改nginx埠號(根據自己需求)

  • cd /etc/nginx/conf.d/

    vim default.conf

    把listen 80改成listen 81

    3.訪問http://ip:81即可看到nginx首頁

    安裝完成訪問時候需要啟動php-fpm,不重啟訪問會出現下載文件,重啟命令如下

    systemctl start php-fpm.service #啟動php-fpm

    systemctl enable php-fpm.service #設置開機啟動

    4.更改nginx配置文件識別php

    vi /etc/nginx/conf.d/default.conf,把之前的#給去掉就可以了,順手改一下

    location ~ .php$ {

    root html;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;

    include fastcgi_params;

    }

    方法二 安裝nginx

    yum install nginx

    啟動nginx,並設置為開機啟動

    systemctl start nginx

    systemctl enable nginx

5.在 /usr/share/nginx/html中新建一個test.php

訪問http://ip:81/test.php即可看到php頁面

修改完成配置記得啟動apache 和php-fpm 哦!

九.負載配置

upstream site{

server 172.16.170.138;

server 172.16.170.139;

}

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log /var/log/nginx/log/host.access.log main;

location / {

root /usr/share/nginx/html;

index index.html index.htm;

proxy_pass http://site;

}

apache 默認目錄 /var/www/html

nginx 默認目錄 /usr/share/nginx/html

升級php版本

centos7 默認安裝php是5.4

查看yum的可安裝的php版本列表

yum provides php

開始升級PHP更新源:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum remove php-common -y #移除系統自帶的php-common

php72版本

yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring

php56版本

yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring #安裝依賴包

查看php版本

php -v

安裝php fpm:

yum install php72w-fpm

yum provides php-fpm #因為我是准備搭建lnmp,所以安裝php-fpm,這里會提示多個安裝源,選擇5.6版本的安裝就可以了

yum install php56w-fpm-5.6.31-1.w7.x86_64 -y

systemctl start php-fpm.service 【啟動】

systemctl enable php-fpm.service【開機自啟動】

CentOS yum有時出現「Could not retrieve mirrorlist 」的解決辦法——resolv.conf的配置

原因:沒有配置resolv.conf

解決方法:

到/etc目錄下配置resolv.conf加入nameserver IP,如:

nameserver 8.8.8.8

nameserver 8.8.4.4

search localdomain

保存再次運行上面的命令就可以。

https://blog.csdn.net/mao834099514/article/details/73470001

nginx目錄 : /usr/share/nginx/html

/etc/nginx/conf.d/default.conf nginx配置目錄

apache目錄 : /var/www/html

/etc/httpd/conf/httpd.conf apache配置文件

nginx 配置域名

cd /etc/nginx

cp default.conf imooc.conf

修改server_name imooc.test.com 以及項目目錄

配置虛擬域名 windows 訪問需要在host增加 linuxip

ServerName www.nine.com

DocumentRoot "/var/www/html/learnlaravel/public"

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

關閉防火牆

setenforce 0

Ⅳ centos7怎麼樣安裝php+mysql+apache

一、安裝apache:
yum install httpd httpd-devel
啟動apache:
systemctl start httpd.service
設置開機自動啟動:systemctl enable httpd.service

此時輸入伺服器的IP地址,應該看到apache的服務頁面,埠不用輸,apache默認就是使用80埠
二、安裝PHP:
yum install php php-devel
重啟apache使php生效
systemctl restart httpd.service
此時可以在目錄:/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
systemctl restart httpd.service

三、安裝MYSQL並設置遠程訪問

yum install mysql
yum install mysql-server
yum install mysql-devel
然後,重啟服務:
$ service mysqld restart

接下來登錄重置密碼:
$ mysql -u root
mysql > use mysql;
mysql > update user set password=password('123456') where user='root';
mysql > exit;

5. 開放3306埠
$ sudo vim /etc/sysconfig/iptables

添加以下內容:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

保存後重啟防火牆:
$ sudo service iptables restart

6. 創建普通用戶並授權
示例(使用root用戶登錄):
mysql > use mysql;
mysql > grant all privileges on *.* to 'root'@'%' identified by '123456';mysql > flushn privileges;

Ⅵ 如何在linux上安裝php5.6,謝謝,

不知道你問的linux,是哪個發行版本,常用的如 ubntu,centos,debian等。

我列一個centos7(伺服器常用這個版本)的安裝方法吧

centos7默認使用yum install 來安裝程序,但默認源安裝的php是5.4的,版本比較低,

要安裝高版本的,要麼下載源代碼手動編譯安裝,但對不熟悉的,萬一出點錯誤,會越搞越亂。我一般使用epel源安裝php,裡面各個版本都有,最新的php7.3

  1. 首先安裝epel

    rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

    這裡面的url是目前我用的,如果提示出錯,就是換url了,可以在電腦上手動打開epel源列表去檢查 epel-release是哪個版本,換上對應的名字

  2. 按版本安裝php

rpm-Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yuminstallphp56wphp56w-mysqlphp56w-pdophp56w-gdphp56w-sslphp56w-mbstringphp56w-cliphp56w-xmlphp56w-bcmath

我這里列的是一些常用的php擴展,如果需要其它的,手動加上即可

如果需要安裝php其它版本,把包名里的56改成對應版本即可 ,如

yuminstallphp71wphp71w-mysqlphp71w-pdophp71w-gdphp71w-sslphp71w-mbstringphp71w-cliphp71w-xmlphp71w-bcmath

yuminstallphp72wphp72w-mysqlphp72w-pdophp72w-gdphp72w-sslphp72w-mbstringphp72w-cliphp72w-xmlphp72w-bcmath

可對應安裝php7.1和php7.2,這種安裝方法,會默認配置好對應的設置,php.ini在/etc/中查找,命令行也默認啟用了 (php-cli)

Ⅶ 阿里雲默認centos7上怎麼安裝php

首先更新系統軟體</str>
$ yum update
安裝nginx</str></str>
1.安裝nginx源
$ yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm2.安裝nginx
$ yum install nginx
3.啟動nginx
$ service nginx start
Redirecting to /bin/systemctl start nginx.service4.訪問http://你的ip/
如果成功安裝會出來nginx默認的歡迎界面
安裝MySQL5.7.*
</str>
1.安裝mysql源</str>
$ yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm2.安裝mysql
$ yum install mysql-community-server
確認一下mysql的版本,有時可能會提示mysql5.63.安裝mysql的開發包,以後會有用
$ yum install mysql-community-devel
4.啟動mysql
$ service mysqld start
Redirecting to /bin/systemctl start mysqld.service5.查看mysql啟動狀態
$ service mysqld status
出現pid
證明啟動成功
6.獲取mysql默認生成的密碼
$ grep 'temporary password' /var/log/mysqld.log2015-12-05T05:41:09.104758Z 1 [Note] A temporary password is generated for root@localhost: %G1Rgns!dD!v</str>
加粗的就是生成的密碼
7.換成自己的密碼
$ mysql -uroot -p
Enter password:輸入上面的密碼
成功輸入後進入一下步,這里你估計會輸入 好幾次才進去8. 更換密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';這個密碼一定要足夠復雜,不然會不讓你改,提示密碼不合法;9.退出mysql;
mysql> quit;
10.用新密碼再登錄,試一下新密碼
$ mysql -uroot -p
Enter password:輸入你的新密碼
11.確認密碼正確後,退出mysql;
mysql> quit;
編譯安裝php7.0.0
</str>
</str>
1.下載php7源碼包</str>
$ cd /root & wget -O php7.tar.gz http://cn2.php.net/get/php-7.0.1.tar.gz/from/this/mirror2.解壓源碼包</str>
$ tar -xvf php7.tar.gz
3.</str>
$ cd php-7.0.1
4.安裝php依賴包</str>
</str>
$ yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel5.編譯配置,這一步我們會遇到很多configure error,我們一一解決,基本都是相關軟體開發包沒有安裝導致</str>
</str>
$ ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
configure error:
1.configure: error: xml2-config not found. Please check your libxml2 installation.
解決:
$ yum install libxml2 libxml2-devel
2.configure: error: Cannot find OpenSSL's <evp.h>
解決:
$ yum install openssl openssl-devel
3.configure: error: Please reinstall the BZip2 distribution解決:
$ yum install bzip2 bzip2-devel
4.configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/解決:
$ yum install libcurl libcurl-devel
5.If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.
解決:
$ yum install libjpeg libjpeg-devel
6.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yesconfigure: error: png.h not found.
解決:
$ yum install libpng libpng-devel
7.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yeschecking for png_write_image in -lpng... yesIf configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
解決:
$ yum install freetype freetype-devel
8.configure: error: Unable to locate gmp.h解決:
$ yum install gmp gmp-devel
9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決:
$ yum install libmcrypt libmcrypt-devel
10.configure: error: Please reinstall readline - I cannot find readline.h解決:
$ yum install readline readline-devel
11.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution解決:
$ yum install libxslt libxslt-devel
6.編譯與安裝
$ make && make install
這里要make好久,要耐心一下
7.添加 PHP 命令到環境變數
$ vim /etc/profile
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改動立即生效執行
$ ./etc/profile

$ source /etc/profile
查看環境變數
$ echo $PATH
查看php版本
$ php -v
8.配置php-fpm
$ cp php.ini-proction /etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf$ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf$ cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm$ chmod +x /etc/init.d/php-fpm
9.啟動php-fpm
$ /etc/init.d/php-fpm start
配置nginx虛擬機,綁定域名</str>
1.
</str>
$ vim /etc/nginx/conf.d/php7.thinkcmf.com.conf這里可以把php7.thinkcmf.com.conf改成自己的域名把下面的內容復制到php7.thinkcmf.com.conf里server{
listen 80;
server_name php7.thinkcmf.com;
root /var/www/html/php7.thinkcmf.com; # 該項要修改為你准備存放相關網頁的路徑location / {
index index.php index.html index.htm;
#如果請求既不是一個文件,也不是一個目錄,則執行一下重寫規則if (!-e $request_filename)
{
#地址作為將參數rewrite到index.php上。
rewrite ^/(.*)$ /index.php/$1;
#若是子目錄則使用下面這句,將subdir改成目錄名稱即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php/$1;}
}
#proxy the php scripts to php-fpm
location ~ \.php {
include fastcgi_params;
##pathinfo支持start
#定義變數 $path_info ,用於存放pathinfo信息set $path_info "";
#定義變數 $real_script_name,用於存放真實地址set $real_script_name $fastcgi_script_name;#如果地址與引號內的正則表達式匹配
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {#將文件地址賦值給變數 $real_script_name
set $real_script_name $1;
#將文件地址後的參數賦值給變數 $path_info
set $path_info $2;
}
#配置fastcgi的一些參數
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;
###pathinfo支持end
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
}
2.重啟nginx
$ service nginx reload
3.
$ vim /var/www/html/php7.thinkcmf.com/index.php</str>
把下面的代碼復制到這個文件 里
<?php
phpinfo();
4.查看訪問http://php7.thinkcmf.com

Ⅷ 如何在centos7上安裝php

您好,安裝PHP的方式可以一步一步的按照教程去安裝,這個可以到網上搜一搜,因為步驟太多,我就不復制粘貼了。但是我這里最推薦的就是使用phpstudy一鍵安裝,沒錯,就是在Linux上一鍵安裝,可以去試一試。

黑馬程序員的PHP是國內最早開設的真正人工智慧課程。課程全面系統,緊跟時代潮流。

Ⅸ 如何在 CentOS 7 / Ubuntu 15.04 上安裝 PHP 框架 Laravel

在 CentOS 7 / Ubuntu 15.04 上安裝 Laravel。如果你是一個 PHP Web 的開發者,你並不需要考慮如何在琳琅滿目的現代 PHP 框架中選擇,Laravel 是最輕松啟動和運行的,它省時省力,能讓你享受到 web 開發的樂趣。Laravel 信奉著一個普世的開發哲學,通過簡單的指導創建出可維護代碼是最優先的,你將保持著高速的開發效率,能夠隨時毫不畏懼更改你的代碼來改進現有功能。
Laravel 安裝並不繁瑣,你只要跟著本文章一步步操作就能在 CentOS 7 或者 Ubuntu 15 伺服器上安裝。
1) 伺服器要求
在安裝 Laravel 前需要安裝一些它的依賴前提條件,主要是一些基本的參數調整,比如升級系統到最新版本,sudo 許可權和安裝依賴包。
當你連接到你的伺服器時,請確保你能通以下命令能成功的使用 EPEL 倉庫並且升級你的伺服器。
CentOS-7
#yum install epel-release
# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#yum update
Ubuntu
#apt-get install python-software-properties
# add-apt-repository ppa:ondrej/php5
#apt-get update
#apt-get install -y php5 mcrypt php5-mcrypt php5-gd
2) 防火牆安裝
系統防火牆和 SELinux 設置對於用於產品應用安全來說非常重要,當你使用測試伺服器的時候可以關閉防火牆,用以下命令行設置 SELinux 成寬容模式(permissive)來保證安裝程序不受它們的影響。
#setenforce0
3) Apache, MariaDB, PHP 安裝
Laravel 安裝程序需要完成安裝 LAMP 整個環境,需要額外安裝 OpenSSL、PDO,Mbstring 和 Tokenizer 等 PHP 擴展。如果 LAMP 已經運行在你的伺服器上你可以跳過這一步,直接確認一些必要的 PHP 插件是否安裝好。
要安裝完整 AMP 你需要在自己的伺服器上運行以下命令。
CentOS
#yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
要在 CentOS 7 上實現 MySQL / Mariadb 服務開機自動啟動,你需要運行以下命令。
#systemctl start httpd
#systemctl enable httpd
#systemctl start mysqld
#systemctl enable mysqld
在啟動 MariaDB 服務之後,你需要運行以下命令配置一個足夠安全的密碼。
#mysql_secure_installation
Ubuntu
#apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql
4) 安裝 Composer
在我們安裝 Laravel 前,先讓我們開始安裝 composer。安裝 composer 是安裝 Laravel 的最重要步驟之一,因為 composer 能幫我們安裝 Laravel 的各種依賴。
CentOS/Ubuntu
在 CentOS / Ubuntu 下運行以下命令來配置 composer 。
# curl -sS https://getcomposer.org/installer | php
#mv composer.phar /usr/local/bin/composer
#chmod+x /usr/local/bin/composer
composer installation
composer installation
5) 安裝 Laravel
我們可以運行以下命令從 github 上下載 Laravel 的安裝包。
#wget https://github.com/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
compose laravel
6) 密鑰
為了加密伺服器,我們使用以下命令來生成一個加密後的 32 位的密鑰。
# php artisan key:generate
Application key []set successfully
現在把這個密鑰放到 'app.php' 文件,如以下所示。
#vim/var/www/laravel-develop/config/app.php
Key encryption
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
Laravel Default
總結
Laravel 框架對於開發網頁應用來說是一個絕好的的工具。所以,看了這篇文章你將學會在 Ubuntu 15 和 CentOS 7 上安裝 Laravel, 之後你就可以使用這個超棒的 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 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 安裝成功!

熱點內容
搭建一個流媒體伺服器 發布:2024-05-05 20:40:59 瀏覽:666
2017中超資料庫 發布:2024-05-05 20:37:25 瀏覽:378
編程包游戲 發布:2024-05-05 20:25:00 瀏覽:608
系統鎖屏忘記密碼如何設置 發布:2024-05-05 20:18:07 瀏覽:759
xp怎樣訪問win7 發布:2024-05-05 20:17:07 瀏覽:870
c語言訪問http 發布:2024-05-05 20:04:14 瀏覽:874
什麼可以配置波爾多葉 發布:2024-05-05 20:00:32 瀏覽:964
cgxrar解壓密碼 發布:2024-05-05 19:47:24 瀏覽:634
ubuntu編譯linux內核 發布:2024-05-05 19:46:05 瀏覽:8
php靜態方法調用對象 發布:2024-05-05 19:24:30 瀏覽:367