Think before you speak, read before you think.

nginx安装| lnmp | apache换为nginx | 禁用apache

by

in

办公室的电脑,拿来用用,试试nginx的特性
初步觉得要是卸载可能比较麻烦,反正电脑空间也大

 

  • 采取不卸载,停止apache服务,并禁止其开机启动的方法

先查看apache服务

#ps -ef | grep apache2

root 1243 1 0 19:50 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1264 1243 0 19:50 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1265。。。。。。apache2 -k start
root 3154 2796 0 20:30 pts/0 00:00:00 grep –color=auto apache2
停止apache2

#service apache2 stop

* Stopping web server apache2 … waiting [ OK ]
重启了果真又出现了,那么说明要在启动上下手

It works!
This is the default web page for this server.

网上查找例子(其他都类似):
删除apache2随机器启动的服务

#update-rc.d -f apache2 remove

Removing any system startup links for /etc/init.d/apache2 …
/etc/rc0.d/K09apache2
/etc/rc1.d/K09apache2
/etc/rc2.d/S91apache2
/etc/rc3.d/S91apache2
/etc/rc4.d/S91apache2
/etc/rc5.d/S91apache2
/etc/rc6.d/K09apache2
奏效

接下来想安装nginx
也不知道是从源里直接安装好还是编译安装好
编译了后没成功,缺少格物致知精神
后来用的lnmp 脚本
nginx是起来了,但是还是有权根问题
对各个文件目录不太熟
导致还是请ihipop来帮忙
经过多次实验,完整安装过程如下(以下内容 added at 2011-8-7):

以下安装在debian下进行(ubuntu下自己有php,不需要,ubuntu的安装方法http://wiki.ubuntu.org.cn/Nginx)

安装基本环境:

apt-get install build-essential
  • 编译安装nginx:

先下载好最新版本的nginxhttp://nginx.org/en/download.html

wget http://nginx.org/download/nginx-0.8.54.tar.gz
 tar vxzf nginx-0.8.54.tar.gz
 cd nginx-0.8.54
 ./configure --with-http_ssl_module
 make && make install

下面为编译里遇到的问题,缺少了某些库,apt-get以后就没有问题了:

./configure: error: the HTTP rewrite module requires the PCRE library.
这时要执行下面命令(因为rewrite模块需要)
apt-get install libpcre3-dev

./configure: error: the HTTP gzip module requires the zlib library.
这时要执行下面命令(因为gzip模块需要)
apt-get install zlib1g-dev

在./configure –with-http_ssl_module时提示如下信息
./configure: error: SSL modules require the OpenSSL library.
这时要执行下面命令(因为OpenSSL模块需要)
apt-get install libssl-dev

  • 安装mysql:

apt-get install mysql-server  php5-mysql

过程中会提示输入mysql根用户密码

  • 安装php:

php5-fpm的源

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
deb http://php53.dotdeb.org stable all

为省力执行下面命令:

echo "deb http://packages.dotdeb.org stable all" >> /etc/apt/sources.list;echo "deb-src http://packages.dotdeb.org stable all" >> /etc/apt/sources.list;echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list

加入后apt-get update出现以下提示

正在读取软件包列表… 完成
W: GPG 错误:http://packages.dotdeb.org stable Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY E9C74FEEA2098A6E
W: GPG 错误:http://php53.dotdeb.org stable Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY E9C74FEEA2098A6E

故通过下面命令导入公钥

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -

apt-get update

apt-get install php5-fpm

至此,lnmp安装完成。

要想成功解译出php,在nginx.conf 里相应 server 部分做如下修改:

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

location ~ \.php$ {
root           /web/;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  /web/$fastcgi_script_name;
include        fastcgi_params;
}

:)EOT


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *