php5.3 nginx编译安装包,Ubuntu 10.10上编译安装LNMP:Nginx 0.8.54+MySQL 5.1.56+PHP-FPM 5.3.6...

本文记录了LNMP在Ubuntu10.10下的编译安装过程,版本如下:

Nginx 0.8.54

MySQL 5.1.56

PHP-FPM 5.3.6

1、编译安装MySQL 5.1.56

#下载

wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.56.tar.gz/from/http://mysql.he.net/

mv index.html mysql-5.1.56.tar.gz

tar -xzvf mysql-5.1.56.tar.gz

cd mysql-5.1.56

#安装编译环境

sudo apt-get install gcc g++ make libncurses5-dev

#配置变量

CFLAGS="-O3"

CXX=gcc

CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"

#configure

./configure --prefix=/usr/local/mysql --enable-assembler --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=gb2312,gbk,utf8,latin1 --without-debug --with-charset=utf8 --with-collation=utf8_general_ci --with-pthread --enable-static --with-plugins=myisam,innobase

#make

make

#install

sudo make install

#add new user/group

sudo useradd mysql

sudo passwd

#权限

cd /usr/local/mysql/

sudo chown -R mysql:mysql ./

#新建

su mysql

sudo ./bin/mysql_install_db --user=mysql

exit

sudo cp share/mysql/my-medium.cnf /etc/my.cnf

#修改my.cnf

vim /etc/my.cnf

#添加如下行

skip-innodb

skip-external-locking

#添加到开机启动、启动服务

sudo cp share/mysql/mysql.server /etc/init.d/mysqld

sudo /etc/init.d/mysqld start

#开机启动:在RunLevel的2 3 4 5中,第15个启动mysql,在0 1 1 6中不启动mysql

sudo update-rc.d mysqld start 15 2 3 4 5 . stop 15 0 1 6 .

#关闭开机启动

sudo update-rc.d -f mysqld remove

#创建ln

sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/

sudo ln -s /usr/local/mysql/bin/mysqldump /usr/bin/

sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/

#root密码 & 删除匿名帐号、测试数据库

mysqladmin -u root password 'new-password'

mysql -u root -p

mysql >> use mysql;

mysql >> delete from user where user='';

mysql >> DROP DATABASE test;

mysql >> flush privileges;

2、编译安装php-fpm

#下载

wget http://us.php.net/distributions/php-5.3.6.tar.bz2

tar -xjvf php-5.3.6.tar.bz2

cd php-5.3.6

#相关库

sudo apt-get install libxml2-dev zlib1g-dev libcurl4-openssl-dev libpng12-dev libmcrypt-dev

#configure

./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --disable-cli --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/etc/sysconfig/php --with-config-file-scan-dir=/etc/sysconfig/php --with-zlib --with-curl --with-gd --with-mhash --enable-mbstring --with-mcrypt --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --disable-pdo --disable-soap --enable-sockets --with-xmlrpc --enable-zip --without-pear

#make

make

#install

sudo make install

#user

cd /usr/local/php

useradd www

sudo chown -R www:www ./

#拷贝php配置

sudo mkdir -p /etc/php

sudo cp php.ini-production /etc/php/php.ini

#配置

sudo vim ./etc/php-fpm.conf

rlimit_files = 1048576

pm.max_children = 10

pm.start_servers = 4

pm.min_spare_servers = 2

pm.max_spare_servers = 10

pm.max_requests = 100

#运行

./sbin/php-fpm

#添加到开机启动

ln -s /usr/local/php/sbin/php-fpm /usr/bin/

vim /etc/rc.local

#start php-fpm at start

echo 134217728 > /proc/sys/kernel/shmmax

php-fpm

#安装APC

wget http://pecl.php.net/get/APC-3.1.6.tgz

tar -xzvf APC-3.1.6.tgz

cd APC-3.1.6

sudo apt-get install autoconf

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

sudo make install

#编辑

vim /etc/sysconfig/php/php.ini

#修改并添加

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"

extension=apc.so

[apc]

apc.enabled = 1

apc.shm_segments = 2

apc.shm_size = 48M

3、编译安装nginx

#下载

wget http://nginx.org/download/nginx-0.8.54.tar.gz

tar -xzvf nginx-0.8.54.tar.gz

#安装相关包

sudo apt-get install libpcre3-dev libmhash-dev

#configure

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module

#make

make

#install

sudo make install

cd /usr/local/nginx

sudo chown -R www:www .

#配置nginx.conf

sudo vim conf/nginx.conf

#如下

user www www;

worker_processes 2;

error_log /usr/local/nginx/logs/error.log;

pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 1048576;

events {

use epoll;

worker_connections 65535;

}

http {

include mime.types;

default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

sendfile on;

tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 60;

#gzip

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.0;

gzip_comp_level 6;

gzip_types text/plain application/x-javascript text/css application/xml;

gzip_vary on;

server {

listen 80;

server_name node11.coder4.com;

root /usr/local/nginx/html;

access_log /usr/local/nginx/logs/node11.coder4.com.access.log main;

location / {

index index.php index.html index.htm;

}

# redirect server error pages to the static page /50x.html

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi_params;

}

#deny htaccess

location ~ /\.ht {

deny all;

}

#ip

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {

expires 30d;

access_log off;

}

}

}

#配置fastcgi_params

sudo vim conf/fastcgi_params

#添加一行

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值