安裝php並使用nginx串連PHP

來源:互聯網
上載者:User

標籤:rod   one   calendar   -o   efault   make   時間   list   remote   

版本是5.6.31

安裝前需要安裝的包:

yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel  freetype-devel -y

編譯如下:

./configure --prefix=/usr/local/php-5.6.31 \
--with-config-file-path=/usr/local/php-5.6.31/etc --with-bz2 --with-curl \
--enable-ftp --enable-sockets --disable-ipv6 --with-gd \
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local \
--with-freetype-dir=/usr/local --enable-gd-native-ttf \
--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \
--with-gettext --with-libxml-dir=/usr/local --with-zlib \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \
--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-xpm-dir=/usr

如果報錯,可以參考:http://www.linuxidc.com/Linux/2014-05/102327.htm 或者 http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html

make 

make install

安裝完成後需要配置Php,開啟php.ini設定檔,修改如下參數為如下值,否則zabbix安裝不了

把安裝源檔案中的php.ini-production複製到/usr/local/php-5.6.31/etc下面,改名為php.ini

修改如下參數:

max_execution_time = 300memory_limit = 128Mpost_max_size = 16Mupload_max_filesize = 2Mmax_input_time = 300date.timezone PRC 然後:cp /usr/local/php-5.6.31/etc/php-fpm.conf.default /usr/local/php-5.6.31/etc/php-fpm.conf 啟動php-fpm
[[email protected] sbin]# ./php-fpm [[email protected] sbin]# netstat -lnt|grep 9000tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN   

 

 

配置nginx串連php

mkdir -p /data/logs/nginx/ # 用於存放nginx日誌

mkdir -p /data/site/zabbixserver.com/ # 網站根目錄vim /data/site/zabbixserver.com/info.php<?phpphpinfo();?>

在nginx.conf的http斷中加上如下內容:

####################################start##############################server {listen 80;server_name zabbixserver.com;access_log /data/logs/nginx/zabbixserver.com.access.log main;index index.php index.html index.html;root /data/site/zabbixserver.com;location /{try_files $uri $uri/ /index.php?$args;}location ~ .*\.(php)?${expires -1s;try_files $uri =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;include fastcgi_params;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;}}################################end################################

 

啟動nginx的時候會報錯,把以下取消注釋就可以了

log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘                      ‘$status $body_bytes_sent "$http_referer" ‘                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

 

啟動nginx後

 

補充一個地方:此時在zabbserver伺服器上使用瀏覽器開啟http://localhost,會開啟nginx的歡迎頁面,但是http://zabbixserver.com會報403;在其它機器上訪問都是403,如果要訪問nginx歡迎頁面,可以修改下設定檔的連接埠號碼,然後加連接埠號碼訪問。

 

不過這時候在zabbixserver伺服器上http://localhost:801

具體為什嗎?過段時間再學這個

 

安裝php並使用nginx串連PHP

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.