Linux伺服器---配置apache支援php

一生有你llx發表於2018-11-24

apache 支援php

php 是最好用的伺服器語言了,Apache對php有很強大的支援    


1 、檢測是否安裝php,如果什麼資訊也沒有,那麼你就要自己安裝php了

[root@localhost ~]#  rpm -qa | grep php

 

2 、安裝php,在終端輸入命令“yum install –y php”

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

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile                                             

Dependency Installed:

  php-cli.i686 0:5.3.3-26.el6           php-common.i686 0:5.3.3-26.el6          

Complete!

[root@localhost ~]# 

 

3 、再次檢測,看是否安裝。看到如下資訊就證明安裝成功了。

[root@localhost ~]#  rpm -qa | grep php

php-cli-5.3.3-26.el6.i686

php-5.3.3-26.el6.i686

php-common-5.3.3-26.el6.i686

[root@localhost ~]# 

 

4 、重新啟動Apache服務

[root@localhost ~]#  service httpd restart

停止  httpd                                                [ 確定 ]

正在啟動  httpd httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

                                                          [ 確定 ]

[root@localhost ~]# 

 

5 、測試php。在“/var/www/html/”目錄下建立一個test.php檔案。然後在瀏覽器輸入“127.0.0.1/test.php”

[root@localhost ~]#  cd /var/www/html/

[root@localhost html]# ls

[root@localhost html]#  touch test.php

[root@localhost html]#  gedit test.php

<?php

    echo "hello php";

?>

可以在瀏覽器看到以下結果

       


6 、安裝gd庫,支援php圖形驗證碼。在終端輸入命令“ yum install -y php-gd

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

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

=============================================================================================================================

 Package                      Arch                       Version                            Repository                  Size

=============================================================================================================================

Installing:

 php-gd                       i686                       5.3.3-26.el6                       base                       105 k

Installing for dependencies:

 libXpm                       i686                       3.5.10-2.el6                       base                        50 k                                                                                        

Dependency Installed:

  libXpm.i686 0:3.5.10-2.el6                                                                                                

Complete!

[root@localhost ~]# rpm -qa | grep php-gd

php-gd-5.3.3-26.el6.i686

[root@localhost ~]# 

 

 

 

 做了一個Linux學習的平臺,目前出來一個雛形,各位可以參考使用
連結: https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ   密碼:n7bk



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29270124/viewspace-2220985/,如需轉載,請註明出處,否則將追究法律責任。

相關文章