1、安装nginx
- # yum -y install pcre-devel
- # groupadd -r nginx
- # useradd -r -g nginx -s /sbin/nologin -M nginx
- # tar xf nginx-1.2.2.tar.gz
# cd nginx-1.2.2- # ./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/ \
- --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
- --http-scgi-temp-path=/var/tmp/nginx/scgi \
- --with-pcre
- # make && make install
为nginx提供启动脚本/etc/rc.d/init.d/nginx,内容前面已经有过了,这里不贴了:
# chmod +x /etc/rc.d/init.d/nginx
# service nginx start
2、安装mysql-5.5.24
- # groupadd -r mysql
- # useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
- # tar xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/
- # cd /usr/local/
- # ln -s mysql-5.5.24-linux2.6-i686/ mysql
- # cd mysql
- # chown -R mysql.mysql .
- # scripts/mysql_install_db --user=mysql --datadir=/mydata/data
- # chown -R root .
复制主配置文件,并编辑修改
# cp support-files/my-large.cnf /etc/my.cnf
# vim /etc/my.cnf
thread_concurrency = 2 //为CPU的个数乘以2
datadir = /mydata/data //需要手动添加
复制service启动脚本
- # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- # service mysqld restart
- # chkconfig --add mysqld
- # chkconfig mysqld on
- # export PATH=/usr/local/mysql/bin/:$PATH
- # echo '/usr/local/mysql/lib/' > /etc/ld.so.conf
- # ldconfig
3、安装php-5.4.4
这里的需要更新这几个软件包
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm
mhash-0.9.2-6.el5.i386.rpm
mhash-devel-0.9.2-6.el5.i386.rpm
- # tar -jxvf php-5.4.4.tar.bz2
- # cd php-5.4.4
- # ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php --with-bz2 --with-curl
- # make
- # make install
- 复制主配置文件
- # cp php.ini-production /etc/php.ini
- 服务脚本
- # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
- # chmod +x /etc/rc.d/init.d/php-fpm
- 修改php-fpm配置文件
- # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
- # vim /usr/local/php/etc/php-fpm.conf
- pid = run/php-fpm.pid
- pm.max_children = 50 最多多少子进程
- pm.start_servers = 5 刚开始启动多少进程
- pm.min_spare_servers = 2 最少多少空闲进程
- pm.max_spare_servers = 8 最多多少空闲进程
- # service php-fpm start
编辑/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;
- }
编辑/etc/nginx/fastcgi_params,添加修改如下内容:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
添加php格式的主页,如下所示:
location / {
root html;
index index.php index.html index.htm;
}
重启服务:
# service nginx restart
写入测试文件,访问查看
# cat /usr/html/index.php
<?php
phpinfo();
?>