首先,设置nginx最新稳定版本的源,还有php-fpm的源
sudo gedit /etc/apt/sources.list
加入源
deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main
deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
然后加入Key,并更新:
apt-key adv –keyserver keyserver.ubuntu.com –recv-keys C300EE8C
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 8D0DC64F
sudo apt-get update
首先, 安装最新稳定版本版本的Nginx
apt-get install nginx
nginx安装好, 我们测试一下OK没
sudo /etc/init.d/nginx start
访问下: http://localhost, OK, 可以访问
注: 如果没有/var/www目录大话,自己创建一个就可以了
然后我们安装php5.3和相关一堆东西
sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json php5-suhosin php5-common php-apc php5-dev
接着安装php5-cgi和 php5-fpm
sudo apt-get install php5-fpm php5-cgi
启动CGI
/etc/init.d/php5-fpm start
接着我们配置nginx: sudo gedit /etc/nginx/site-available/default
我的配置如下:
server {
listen 80;
server_name localhost;
root /var/www;
access_log /var/log/nginx/localhost.access.log;
error_page 404 /404.html;
location / {
index index.html index.htm index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
root /var/www;
}
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_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;
}
location ~ /\.ht {
deny all;
}
}
upstream backend {
server 127.0.0.1:9000;
}
配置站点2
sudo cp default arlicle
然后将server_name改为:www.arlicle.com arlicle.com;
对应的目录也进行修改 然后执行下面大命令启动arlicle 站点
sudo ln -s /etc/nginx/sites-available/arlicle /etc/nginx/sites-enabled/arlicle
sudo /etc/init.d/nginx reload
访问测试一下,正常.
最后我们安装加速引擎:
sudo pecl install memcache
sudo apt-get install libpcre3-dev
sudo pecl install apc
注:
将phpmyadmin加入访问:
ln -s /usr/share/phpmyadmin /var/www/phpmyadmin 这样就可以访问了
设置nginx上传文件大小: /etc/nginx/nginx.conf
clientmaxbody_size 30M;
修改php.ini文件: /etc/php5/fpm
postmaxsize = 30M
配置nginx 访问php时不存在php的404报错, 在配置文件中加入
error_page 404 /404.html;
转载请注明:爱开源 » Ubuntu 10.04 + nginx + php5 + php-fpm安装,并进行多站点配置