Nginx
的主要应用类别
1
使用
Nginx
结合
FastCGI
运行
PHP
,
JSP,Perl
等程序
2
使用
Nginx
作反向代理,负载均衡,规则过滤
3
使用
Nginx
运行静态
HTML
页,图片
4
Nginx
与其他新技术的结合应用
安装
MySQL
的方法:
1
使用
RPM
包
2
使用二进制文件安装
3
使用源代码包安装
安装
LEMP
步骤:
安装
nginx
1 yum install gcc openssl-devel pcre-devel zlib-devel
2 groupadd nginx
3 useradd -g nginx -s /bin/false -M nginx
4 ./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
5 make && make install
安装
MySQL
1 tar zxvf mysql- 5.1.45 -linux-i686-blibc23.tar.gz -C /usr/local
2 cd /usr/local
3 ln �Csv mysql- 5.1.45 -linux-i686-glibc23/ mysql
4 cd mysql
5 groupadd mysql
6 useradd �Cg mysql �Cs /sbin/nologin �CM mysql
7 chown mysql:mysql . �CR
8 scripts/mysql_install_db --user=mysql
9 chown �CR root .
10 chown �CR mysql data
11 bin/mysql_safe --user=mysql &
12 vim /etc/profile (
添加
PATH=$PATH:/usr/local/bin)
13 . /etc/profile
14 vim /etc/ld.so.conf/mysql.conf(
添加
/usr/local/mysql/lib)
15 ldconfig �Cv
16 ln �Csv /usr/local/mysql/include /usr/include/mysql
17 cp support-files/mysql.server /etc/init.d/mysqld
18 chkconfig �Cadd mysqld
19 chkconfig mysqld on
20 cp support-files/my-large.cnf /etc/my.cnf
21 service mysqld start
安装
PHP
1 tar zxvf libevent- 1.4.14 b-stable.tar.gz
2 cd libevent- 1.4.14 b-stable
3 ./configure
4 make && make install
5 tar zxvf libiconv- 1.13.1 .tar.gz
6 cd libiconv- 1.13.1
7 ./configure
8 make && make install
9 tar jxvf php- 5.3.3 .tar.bz2
10 cd jxvf php- 5.3.3
11 ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --with-libevent-dir=/usr/local --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-iconv-dir=/usr/local
12 make ZEND_EXTRA_LIBS='-liconv'
13 make install
配置
PHP
1 cp php.ini-production /usr/local/php/etc/php.ini
2 cd /etc/local/php/etc
3 cp php-fpm.conf.default php-fpm.conf
4 vim php-fpm.conf(
启动
[global]
的
pid error_log [www]
的
listen.allowed_clients=127.0.0.1
pm.max_children pm.start_servers pm.max_spare_servers pm.max_requests)
5 /usr/local/php/sbin/php-fpm &
6 vim /etc/rc.d/rc.local(
添加
/usr/local/php/sbin/php-fpm)
7 vim /etc/nginx/nginx.conf
启用如下选项:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
8 service nginxd restart