Ubuntu Server 10.04+Nginx+MySQL+PHP+eAccelerator

56 篇文章 0 订阅
34 篇文章 0 订阅
 本来想在Ubuntu Server 10.04用LAMP的,但是服务器配置较低,前辈推荐用nginx, 下篇再写LAMP吧。

之所以用nginx没用apache,是因为nginx的效率更高一些,尤其是对一些低配置的服务器

1、安装Ubuntu server 10.04,其中安装语言选的en,时区chongqing,服务只安装ssh,其他全部用默认就行。
提示:以上安装过程完成后,建议用其他计算机登录服务器,windows系统可以用putty,linux系统直接在终端用命令就可以:



代码:ssh 登录名@服务器ip
因为以下过程得输入大量命令和代码,在客户机上直接粘贴即可(在windows下的putty中单击右键即可把剪贴板中的内容粘贴到终端)。
2、添加源:
代码:sudo vi /etc/apt/sources.list
添加如下:
代码:deb http://archive.Ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb http://archive.Ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://archive.Ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://archive.Ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse
deb-src http://archive.Ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://archive.Ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
deb-src http://archive.Ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb-src http://archive.Ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse
deb http://ppa.launchpad.net/jdub/devel/Ubuntu hardy main
注:最后一行是最新版nginx的源(目前是0.8.36)。
3、更新
代码:sudo apt-get update
4、安装网站系统
代码:sudo apt-get install mysql-server mysql-client nginx php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-common php5-ming php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl spawn-fcgi
5、设置开机启动fastcgi进程
代码:sudo vi /etc/rc.local
在exit 0这一行前面添加下一行
代码:/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -C 4 -P /var/run/fastcgi-php.pid
6、创建网站、日志目录(我的网站个人目录是Ubuntu,以下命令用你的个人目录替换其中的ubuntu即可)
代码:mkdir /home/Ubuntu/www -p
mkdir /home/Ubuntu/log -p
ln -s /usr/share/phpmyadmin /home/Ubuntu/www/phpmyadmin
7、配置nginx
代码:sudo vi /etc/nginx/nginx.conf
具体配置网上可以搜到,我的配置:
代码:user www-data;
worker_processes 2;
error_log /dev/null crit;
pid /var/run/nginx.pid;
events {
worker_connections 3000;
}
http {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/css text/xml text/plain application/x-javascript application/xml application/pdf application/x-perl application/x-tcl application/msword application/rtf application/vnd.ms-excel application/vnd.ms-powerpoint application/vnd.wap.xhtml+xml image/x-ms-bmp;
gzip_disable "MSIE [1-6] \.";
gzip_vary on;
output_buffers 4 32k;
client_max_body_size 20m;
server {
listen 80;
server_name localhost;
charset utf-8,gb2312;
access_log /home/Ubuntu/log/access.log;
location / {
root /home/Ubuntu/www;
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "/";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico)$ {
root /home/Ubuntu/www;
access_log off;
expires 30d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/Ubuntu/www;
}
fastcgi_param SCRIPT_FILENAME /home/Ubuntu/www/$real_script_name;
fastcgi_param path_info $path_info;
include /etc/nginx/fastcgi_params;
}
}8、下载并安装eaccelerator(http://www.eaccelerator.net/),最新版:Release-0.9.6 - 2010/02/04 。
代码:sudo apt-get install php5-dev
wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2 //下载



tar zvf eaccelerator-0.9.6.tar.bz2 //解压
cd eaccelerator-0.9.6
mkdir /tmp/eaccelerator //创建缓存目录
chmod 0777 /tmp/eaccelerator //设置为可读写
cp control.php /home/Ubuntu/www/control.php //复制控制程序到网站目录,通过http://网站名/control.php访问,默认帐号为admin,密码为eAccelertor,可编辑此文件修改。
phpize
sudo ./configure --enable-eaccelerator=shared
sudo make
sudo make install
sudo vi /etc/php5/cgi/php.ini
在配置文件最后加上:
代码:zend_extension="/usr/lib/php5/20090626+lfs/eaccelerator.so"
eaccelerator.shm_size="16"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值