Linux/Unix下nginx+php安装简明教程
一、安装nginx: 1. 安装pcre库,nginx的rewrite模板需用到pcre库: 1. mkdir -p /works 2. cd /works 3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz 4. tar -zxvf pcre-8.20.tar.gz 5. ./configure 6. make make install 7
一、安装nginx:
1. 安装pcre库,nginx的rewrite模板需用到pcre库:
1. mkdir -p /works
2. cd /works
3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz
4. tar -zxvf pcre-8.20.tar.gz
5. ./configure
6. make && make install
7. cd ..
2. 安装nginx: www.2cto.com
1. wget http://nginx.org/download/nginx-1.0.10.tar.gz
2. tar -zxvf nginx-1.0.10.tar.gz
3. cd nginx-1.0.10
4. ./configure
5. make && make install
6. cd ..
3. 新建用户和组:
1. groupadd www
2. useradd -r -g www www
二、安装PHP5
1. 安装依赖包:
1. libcurl:
2. wget http://curl.haxx.se/download/curl-7.23.1.tar.gz
3. tar -zxvf curl-7.23.1.tar.gz
4. cd curl-7.23.1/
5. ./configure
6. make && make install
7. cd ..
libxml2:
1. wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz
2. tar -zxvf libxml2-2.7.6.tar.gz
3. cd libxml2-2.7.6
4. ./configure
5. make && make install
6. cd ..
libxslt:
1. wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
2. tar -zxvf libxslt-1.1.24.tar.gz
3. cd libxslt-1.1.24
4. ./configure make && make install
5. cd ..
freetype:
1. wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz
2. tar -zxvf freetype-2.4.6.tar.gz
3. cd freetype-2.4.6 ./configure
4. make && make install
5. cd ..
libpng:
1. wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz?download"
2. tar -zxvf libpng-1.5.6.tar.gz
3. cd libpng-1.5.6 ./configure
4. make && make install
5. cd ..
libjpeg:
1. wget http://ijg.org/files/jpegsrc.v8c.tar.gz
2. tar -zxvf jpegsrc.v8c.tar.gz
3. cd jpeg-8c/
4. ./configure
5. make && make install
6. cd ..
2. 安装php5和php-fpm:
1. wget http://museum.php.net/php5/php-5.2.16.tar.gz
2. wget http://php-fpm.org/downloads/php-5.2.16-fpm-0.5.14.diff.gz
3. tar -zxvf php-5.2.16.tar.gz
4. gunzip php-5.2.16-fpm-0.5.14.diff.gz
5. cd php-5.2.16/
6. patch -p1
7.
8. ./configure \
9. --with-curl \
10. --enable-calendar \
11. --with-xsl \
12. --with-libxml-dir \
13. --enable-ftp \
14. --with-gd \
15. --with-freetype-dir \
16. --with-jpeg-dir \
17. --with-png-dir \
18. --enable-mbstring \
19. --with-zlib \
20. --enable-shared \
21. --with-mysql \
22. --enable-fastcgi \
23. --enable-fpm
24. ./configure && make && make install
修改php-fpm的配置文件/usr/local/etc/php-fpm.conf,设置执行php-fpm的用户和组名:
大约在第62行:
1. Unix user of processes
2.
3. Unix group of processes
4.
修改为:
1. Unix user of processes
2.
3. Unix group of processes
4.
启动php-fpm:
1. /usr/local/sbin/php-fpm start
2. lsof -i:9000
3. netstat -ant|grep 9000
4. #9000为php-fpm的默认端口,可以在/usr/local/etc/php-fpm.conf中修改。
修改nginx配置文件/usr/local/nginx/conf/nginx.conf,我的nginx配置文件如下:
1. worker_processes 10;
2. events {
3. worker_connections 1024;
4. }
5. http {
6. include mime.types;
7. default_type application/octet-stream;
8. sendfile on;
9. keepalive_timeout 65;
10. gzip on;
11. server {
12. listen 80;
13. server_name ead;
14. root /data/faceshow/www;
15. location / {
16. root html;
17. index index.php index.html index.htm;
18. }
19. error_page 500 502 503 504 /50x.html;
20. location = /50x.html {
21. root html;
22. }
23.
24. #此段代码为关键
25. location ~ \.php$ {
26. fastcgi_pass 127.0.0.1:9000; #对应php-fmp的端口
27. fastcgi_index index.php;
28. fastcgi_param SCRIPT_FILENAME /data/faceshow/www/$fastcgi_script_name;
29. #php文件的物理路径
30. include fastcgi_params;
31. }
32.
33. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
34. {
35. expires 30d;
36. }
37. location ~ .*\.(js|css)?$
38. {
39. expires 1h;
40. }
41. }
42. }
43.
启动nginx:
1. /usr/local/nginx/bin/nginx
2. /usr/local/nginx/bin/nginx -s reload
三、常见问题:
问题:nginx ./configure时报如下错误
1. ./configure: error: the HTTP rewrite module requires the PCRE library.
2. You can either disable the module by using --without-http_rewrite_module
3. option, or install the PCRE library into the system, or build the PCRE library
4. statically from the source with nginx by using --with-pcre=
解决:这是由于未PCRE库,请安装PCRE库在运行./configure。也可以使用带--without-http_rewrite_module参数进行./configure,但是这将导致nginx不支持rewrite功能!
四、相关文件下载地址:
libcurl: http://curl.haxx.se/download.html
libxml2:ftp://xmlsoft.org/libxml2/
libxslt:ftp://xmlsoft.org/libxml2/
libpng:http://www.libpng.org/pub/png/libpng.html
libjpeg: http://ijg.org/files/
freetype:http://download.savannah.gnu.org/releases/freetype/
pcre:http://www.pcre.org/
nginx:http://nginx.org/en/download.html
php-fpm:http://php-fpm.org/
php5:http://www.php.net/releases/
MySQL:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors
摘自 爱E族

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Linux系統的五個基本組件是:1.內核,2.系統庫,3.系統實用程序,4.圖形用戶界面,5.應用程序。內核管理硬件資源,系統庫提供預編譯函數,系統實用程序用於系統管理,GUI提供可視化交互,應用程序利用這些組件實現功能。

要查看 Git 倉庫地址,請執行以下步驟:1. 打開命令行並導航到倉庫目錄;2. 運行 "git remote -v" 命令;3. 查看輸出中的倉庫名稱及其相應的地址。

雖然 Notepad 無法直接運行 Java 代碼,但可以通過借助其他工具實現:使用命令行編譯器 (javac) 編譯代碼,生成字節碼文件 (filename.class)。使用 Java 解釋器 (java) 解釋字節碼,執行代碼並輸出結果。

在 Sublime 中運行代碼的方法有六種:通過熱鍵、菜單、構建系統、命令行、設置默認構建系統和自定義構建命令,並可通過右鍵單擊項目/文件運行單個文件/項目,構建系統可用性取決於 Sublime Text 的安裝情況。

Linux的主要用途包括:1.服務器操作系統,2.嵌入式系統,3.桌面操作系統,4.開發和測試環境。 Linux在這些領域表現出色,提供了穩定性、安全性和高效的開發工具。

要安裝 Laravel,需依序進行以下步驟:安裝 Composer(適用於 macOS/Linux 和 Windows)安裝 Laravel 安裝器創建新項目啟動服務訪問應用程序(網址:http://127.0.0.1:8000)設置數據庫連接(如果需要)

Visual Studio Code (VSCode) 是一款跨平台、開源且免費的代碼編輯器,由微軟開發。它以輕量、可擴展性和對眾多編程語言的支持而著稱。要安裝 VSCode,請訪問官方網站下載並運行安裝程序。使用 VSCode 時,可以創建新項目、編輯代碼、調試代碼、導航項目、擴展 VSCode 和管理設置。 VSCode 適用於 Windows、macOS 和 Linux,支持多種編程語言,並通過 Marketplace 提供各種擴展。它的優勢包括輕量、可擴展性、廣泛的語言支持、豐富的功能和版
