在Ubuntu/Debian上快速安装PHP-fpm 5.3和Nginx[服务器安全]
本文“在Ubuntu/Debian上快速安装PHP-fpm 5.3和Nginx[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
本日又搞了VPS玩,惋惜的是他们并不供应archlinux的系统,没办法只好挑选Debian了,但是lenny中的PHP版本都太老了些,更不大概包含fpm了,也不想再浪费时间自己编译了,于是谷歌一把后找到了一个供应PHP-fpm 5.3的源,并且常用的模块都有供应,所以就直接安装了,简单记录下安装历程.
1、安装Nginx
Nginx版本不需求太新,用官方源里的就很好,最少够安定
sudo apt-get install nginx简单编辑下它的默许配置,一会儿来测试可否与PHP正常的工作
sudo vim /etc/nginx/sites-available/default改完后它看起来差不多是这个模样
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
## Default location
location / {
root /var/www;
index index.php;
}
## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
root /var/www;
}
## Parse all .php file in the /var/www directory
location ~ .php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}
2、预备工作
假如用的是Ubuntu系统的话需求手动安装两个包、Debian则不需求
cd /tmp
wget http://us.archive.Ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_i386.deb
wget http://us.archive.Ubuntu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu0.2_i386.deb
sudo dpkg -i *.deb假如用的amd64的系统请将以上两个包中的i386改成amd64
3、增添非官方源,安装PHP-fpm
sudo echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list更新源
sudo apt-get update安装PHP环境
sudo apt-get install php5-cli php5-common php5-suhosin上面安装的是CLI的PHP,接下来安装CGI、fpm
sudo apt-get install php5-fpm php5-cgi需求其他的模块大概扩大可以自行安装,这里摆列下这个源里供应的全部模块与扩大
php5-curl_5.3.2-0.dotdeb.1_i386.deb
php5-dbg_5.3.2-0.dotdeb.1_i386.deb
php5-dev_5.3.2-0.dotdeb.1_i386.deb
php5-enchant_5.3.2-0.dotdeb.1_i386.deb
php5-fpm_5.3.2-0.dotdeb.1_i386.deb
php5-gd_5.3.2-0.dotdeb.1_i386.deb
php5-gmp_5.3.2-0.dotdeb.1_i386.deb
php5-imap_5.3.2-0.dotdeb.1_i386.deb
php5-interbase_5.3.2-0.dotdeb.1_i386.deb
php5-ldap_5.3.2-0.dotdeb.1_i386.deb
php5-mcrypt_5.3.2-0.dotdeb.1_i386.deb
php5-mysql_5.3.2-0.dotdeb.1_i386.deb
php5-odbc_5.3.2-0.dotdeb.1_i386.deb
php5-pgsql_5.3.2-0.dotdeb.1_i386.deb
php5-pspell_5.3.2-0.dotdeb.1_i386.deb
php5-recode_5.3.2-0.dotdeb.1_i386.deb
php5-snmp_5.3.2-0.dotdeb.1_i386.deb
php5-sqlite_5.3.2-0.dotdeb.1_i386.deb
php5-sybase_5.3.2-0.dotdeb.1_i386.deb
php5-tidy_5.3.2-0.dotdeb.1_i386.deb
php5-xmlrpc_5.3.2-0.dotdeb.1_i386.deb
php5-xsl_5.3.2-0.dotdeb.1_i386.deb
php5_5.3.2-0.dotdeb.1_all.deb
php5-apc_5.3.2-0.dotdeb.1_i386.deb
php5-ffmpeg_5.3.2-0.dotdeb.1_i386.deb
php5-geoip_5.3.2-0.dotdeb.1_i386.deb
php5-http_5.3.2-0.dotdeb.1_i386.deb
php5-imagick_5.3.2-0.dotdeb.1_i386.deb
php5-memcache_5.3.2-0.dotdeb.1_i386.deb
php5-spplus_5.3.2-0.dotdeb.1_i386.deb
php5-ssh2_5.3.2-0.dotdeb.1_i386.deb
php5-suhosin_5.3.2-0.dotdeb.1_i386.deb
php5-xcache_5.3.2-0.dotdeb.1_i386.deb
php5-xdebug_5.3.2-0.dotdeb.1_i386.deb
4、测试运行
启动Nginx与PHP-Fpm
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php5-fpm restart接下来在/var/www/下成立个index.php文件,然后写入PHP的测试函数
<?php phpinfo(); ?>然后拜候,呈现PHP环境信息则表示运行正常
查看错误信息
sudo tail /var/log/nginx/error.log
以上是“在Ubuntu/Debian上快速安装PHP-fpm 5.3和Nginx[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |