Linux下搭建nginx php環境


下載安裝所需包

openssl-1.0.1i.tar.gz

zlib-1.2.8.tar.gz

pcre-8.35.tar.gz

nginx-1.7.4.tar.gz

以上為nginx依賴文件

libmcrypt-2.5.7.tar.gz

php-5.3.28.tar.gz

以上為php依賴文件

 

 

依次安裝

1.安裝openssl-1.0.1i.tar.gz

[root@localhost mrms]# tar -zxvf openssl-1.0.1i.tar.gz

[root@localhost mrms]# cd openssl-1.0.1i.tar.gz

[root@localhost openssl-1.0.1i.tar.gz]# ./config 

[root@localhost openssl-1.0.1i.tar.gz]# make && make install

2.安裝zlib-1.2.8.tar.gz

[root@localhost mrms]# tar -zxvf zlib-1.2.8.tar.gz

[root@localhost mrms]# cd zlib-1.2.8

[root@localhost zlib-1.2.8]# ./configure 

[root@localhost zlib-1.2.8]# make && make install

3.安裝pcre-8.35.tar.gz

[root@localhost mrms]# tar -zxvf pcre-8.35.tar.gz

[root@localhost mrms]# cd pcre-8.35

[root@localhost pcre-8.35]# ./configure 

[root@localhost pcre-8.35]# make && make install

 4.安裝 nginx-1.7.4.tar.gz

[root@localhost mrms]# tar -zxvf nginx-1.7.4.tar.gz

[root@localhost mrms]# cd nginx-1.7.4

[root@localhost nginx-1.7.4]# ./configure --with-pcre=../pcre-8.35 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.1i

[root@localhost nginx-1.7.4]# make && make install

至此Nginx的安裝完成!

第三步:檢測是否安裝成功

[root@localhost nginx-1.2.6]# cd  /usr/local/nginx/sbin

[root@localhost sbin]# ./nginx -t

出現如下所示提示,表示安裝成功

 

啟動nginx

[root@localhost sbin]# ./nginx

查看端口

[root@localhost sbin]# netstat -ntlp

結果如下

 

 

接着安裝libmcrypt-2.5.7.tar.gz, 這個文件是安裝php所需

 

注意:configure: error: mcrypt.h not found. Please reinstall libmcrypt.此錯誤由libmcrypt引起

[root@localhost mrms]# tar -zxvf libmcrypt-2.5.7.tar.gz

[root@localhost mrms]# cd libmcrypt-2.5.7

[root@localhost libmcrypt-2.5.7]# ./configure 

[root@localhost libmcrypt-2.5.7]# make && make install
 
        

最后安裝php

[root@localhost mrms]# tar -zxvf php-5.3.28.tar.gz

[root@localhost mrms]# cd php-5.3.28

[root@localhost php-5.3.28]#./configure --prefix=/home/opt/php --with-config-file-path=/home/opt/php/etc --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-mbstring --with-mcrypt --with-mhash --enable-fpm --with-gd --enable-gd-native-ttf --with-curl --with-openssl 
[root@localhost php-5.3.28]# make && make install
到此php就安裝成功了,然后啟動php-fpm就可以了。
接下去就是配置nginx訪問目錄了,如出現php文件無法運行可以檢查下fastcgi_param文件,我這里出現過一種這個情況,然后我在里面添加了fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;就OK了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM