centos7源碼部署php,設置安裝源centos7

本文目錄一覽:

求大神指導Centos7 源碼編譯安裝Nginx+PHP 配置動靜分離

這個是我的服務的實際 將配置Nginx實現動靜分離,對php頁面的請求轉發給LAMP處理,而靜態頁面交給Nginx,以實現動靜分離。客戶請求靜態數據給Nginx,Nginx直接應答客戶端,當請求動態數據到Nginx時,Nginx讓客戶端去找LAMP,通過代理的方式,LAMP就和客戶端連接了。分別配置動態分離和靜態分離

(1)架設並調試後端LAMP架構,指定的域名,IP地址為xxxx,創建動態頁面test.php。

(2)配置Nginx(xxxx)處理動態頁面請求,並把域名改為 chaodiquan.com 在server{};段中加入以下代碼,檢測語法後,重啟Nginx

(3)客戶端輸入xxxx/test.php 成功後動態分離就實現了,接下來再配置靜態分離

(4)配置Nginx處理靜態頁面請求,在server{};中加入以下代碼,檢測語法後,重啟Nginx

location ~ .*\.(gif|jpg|jpeg|bmp|swf)$  {    #這段代碼意思是任意網址以這5種格式為結尾就到Nginx根目錄下的html文件夾尋找資源

root   html;

expires   1d;                                         #緩存一天}

(5)在nginx的html目錄中,放入圖片aa.jpg,然後在apache的動態測試頁test.php中添加

html

body

img src=”aaaa/aa.jpg”

/body

/html

(6)客戶端輸入xxxx/test.php測試,由於test.php是動態頁面,因此客戶端會找到LAMP架構中的Apache,然後調取圖片aa.jpg是靜態數據,所以從Nginx提取,最後反饋給客戶端。這個是

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

首先更新系統軟體/str

$ yum update

安裝nginx/str/str

1.安裝nginx源

$ yum localinstall .安裝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 .安裝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 .解壓源碼包/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-production /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/ /usr/local/php/etc/php-fpm.d/ 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.查看訪問

centos7系統源碼編譯安裝PHP7.3.5版本

新增系統用戶組和用戶:

下載 PHP7.3.5

[root@localhost ~]# mkdir devdir

[root@localhost ~]# cd devdir/

[root@localhost devdir]# wget

-bash: wget: 未找到命令

[root@localhost devdir]# rpm -qa|grep wget

[root@localhost devdir]# yum -y install wget

[root@localhost devdir]# rpm -qa|grep wget

wget-1.14-18.el7.x86_64

下載PHP7 解壓 編譯

wget -c

編譯參數解釋

–with-fpm-user=webu –with-fpm-group=webg 添加PHP運行用戶和用戶組

配置信息出錯:

下載gcc軟體編譯器 yum install -y gcc

configure: error: libxml2 not found. Please check your libxml2 installation.

下載libzip-1.5.2.tar.gz

解決libzip 和cmake版本問題

重新配置PHP7編譯環境參數

libzip-1.5.2 無法安裝,已經取消了。

提示off_t類型沒有定義 undefind,解決方法:

編譯安裝

測試PHP是否安裝成功

轉載自:

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/303504.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-31 11:50
下一篇 2024-12-31 11:50

相關推薦

  • PHP和Python哪個好找工作?

    PHP和Python都是非常流行的編程語言,它們被廣泛應用於不同領域的開發中。但是,在考慮擇業方向的時候,很多人都會有一個問題:PHP和Python哪個好找工作?這篇文章將從多個方…

    編程 2025-04-29
  • 雲智直聘 源碼分析

    本文將會對雲智直聘的源碼進行分析,包括前端頁面和後端代碼,幫助讀者了解其架構、技術實現以及對一些常見的問題進行解決。通過本文的閱讀,讀者將會了解到雲智直聘的特點、優勢以及不足之處,…

    編程 2025-04-29
  • PHP怎麼接幣

    想要在自己的網站或應用中接受比特幣等加密貨幣的支付,就需要對該加密貨幣擁有一定的了解,並使用對應的API進行開發。本文將從多個方面詳細闡述如何使用PHP接受加密貨幣的支付。 一、環…

    編程 2025-04-29
  • 使用PHP foreach遍歷有相同屬性的值

    本篇文章將介紹如何使用PHP foreach遍歷具有相同屬性的值,並給出相應的代碼示例。 一、基礎概念 在講解如何使用PHP foreach遍歷有相同屬性的值之前,我們需要先了解幾…

    編程 2025-04-28
  • Python網站源碼解析

    本文將從多個方面對Python網站源碼進行詳細解析,包括搭建網站、數據處理、安全性等內容。 一、搭建網站 Python是一種高級編程語言,適用於多種領域。它也可以用於搭建網站。最常…

    編程 2025-04-28
  • 源碼是什麼

    源碼是一段計算機程序的原始代碼,它是程序員所編寫的可讀性高、理解性強的文本。在計算機中,源碼是指編寫的程序代碼,這些代碼按照一定規則排列,被計算機識別並執行。 一、源碼的組成 源碼…

    編程 2025-04-27
  • PHP獲取301跳轉後的地址

    本文將為大家介紹如何使用PHP獲取301跳轉後的地址。301重定向是什麼呢?當我們訪問一個網頁A,但是它已經被遷移到了另一個地址B,此時若伺服器端做了301重定向,那麼你的瀏覽器在…

    編程 2025-04-27
  • Go源碼閱讀

    Go語言是Google推出的一門靜態類型、編譯型、並髮型、語法簡單的編程語言。它因具有簡潔高效,內置GC等優秀特性,被越來越多的開發者所鍾愛。在這篇文章中,我們將介紹如何從多個方面…

    編程 2025-04-27
  • PHP登錄頁面代碼實現

    本文將從多個方面詳細闡述如何使用PHP編寫一個簡單的登錄頁面。 1. PHP登錄頁面基本架構 在PHP登錄頁面中,需要包含HTML表單,用戶在表單中輸入賬號密碼等信息,提交表單後服…

    編程 2025-04-27
  • Python怎麼看源碼

    本文將從以下幾個方面詳細介紹Python如何看源碼,幫助讀者更好地了解Python。 一、查看Python版本 在查看Python源碼之前,首先需要確認Python版本。可以在命令…

    編程 2025-04-27

發表回復

登錄後才能評論