一、编译安装nginx
yum –y install pcre-devel zlib-devel
useradd –M –s /sbin/nologin nginx
tar –zxf nginx-1.0.0.8.tar.gz
cd nginx-1.0.0.8
yum -y install *gcc*
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-
http_stub_status_module
yum -y install make
make
make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
nginx -t
nginx
netstat -anpt | grep nginx
编写nginx启动脚本
vim /etc/init.d/nginx
#!/bin/bash
#chkconfig: - 99 20
#description:Nginx Server
PROG="/usr/local/nginx/sbin/nginx" //主程序路径
PIDF="/usr/local/ngnix/logs/nginx.pid" //pid 存放路径
case "$1" in
start)
$PROG
;;
STOP)
kill –s OUIT $(cat $PIDE)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
chmod +x /etc/init.d/nginx
ckkconfig --add nginx
vim /usr/local/nginx/conf/nginx.conf
在47行添加
location ~ /status {
stub_status on;
access_log off;
}
service nginx restart
基于域名的虚拟主机
mkdir -p /var/www/benet
echo "<h1>WWW.BENET.COM</h1>" >/var/www/benet/index.html
mkdir -p /var/www/accp
echo "<h1>WWW.ACCP.COM</h1>" >/var/www/accp/index.html
cd /usr/local/ngnix/conf
vim benet.conf
server {
listen 80;
server_name www.benet.com;
charset utf-8;
access_log logs/benet.access.log;
location /{
root /var/www/benet;
index index.html;
}
}
vim accp.conf
server {
listen 80;
server_name www.accp.com;
charset utf-8;
access_log logs/accp.access.log;
location /{
root /var/www/accp;
index index.html;
}
}
vim nginx.conf
添加
include benet.conf
include accp.conf
二、安装mysql数据库
(1)安装
tar -zxf mysql-5.1.55.tar.gz
cd mysql-5.1.55
yum -y install ncurses-devel
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-
clollation=utf8_general_ci --with-extra-charsets=gbk,gb2312
make
make install
(2)优化调整
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
ln -s /usr/local/mysql/bin/* /usr/local/bin/
ln -s /usr/local/mysql/lib/mysql/* /usr/lib/
ln -s /usr/local/mysql/include/mysql/* /usr/include/
(3)初始化数据库
useradd -M -u 27 -s /sbin/nologin mysql
id mysql
cd /usr/local/mysql/bin/
./mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var/
(4)启动mysql数据库
service mysqld start
mysqladmin -u root password 'pwd123'
mysql -u root -p
三、php的编译安装
tar zxf php-5.3.6.tar.gz
cd php-5.3.6
提前需要安装的软件包
yum -y install gd
yum -y install gd-devel
yum -y install libpng-delve
yum -y install libpng-static
yum -y install lixm12-devel
ln -s /usr/lib64/* /usr/lib
./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql/
--with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm
make
make test
make install
cp php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/* /usr/local/bin/
ln -s /usr/local/php5/sbin/* /usr/local/sbin/
tar -zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cd ZendGuardLoader-php-5.3-linux-glibc23-x86_64
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
添加以上两行:
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
配置Nginx支持php环境
启用php-fpm进程
默认监听端口9000
cd /usr/local/php5/etc
cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf
25 pid = run/php-fpm.pid
122 user = nginx
123 group = nginx
157 pm.start_servers = 20
162 pm.min_spare_servers = 5
167 pm.max_spare_servers = 35
/usr/local/sbin/php-fpm
netstat -anpt | grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
29693/php-fpm
在配置文件中(调用本机的php-fpm)
server {
listen 80;
server_name www.benet.com;
charset utf-8;
access_log logs/benet.access.log;
location / {
root /var/www/benet; //本次实验用于独立的配置文件中,不是针对全局配置
index index.php index.html;
}
location ~ \.php$ {
root /var/www/benet;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
vim /var/www/benet/test.php
<?php
phpinfo;
?>
四、在LEMP平台中部署Web应用
tar jxf SKYUC_3.2.2_Free_For_PHP5.3.tar.bz2
mv SKYUC_3.2.2_Free_For_PHP5.3/wwwroot/ /var/www/benet/skyuc
cd /var/www/benet/skyuc/
chown -R nginx.nginx admincp/ data/ templates/ upload/
mysql -uroot -p
create database skyucdb;
grant all on skyucdb.* to runskyuc@localhost identified by 'sky@uc123';
访问http://www.benet.com/skyuc/install/install.php
完成安装后,转移install目录权限
mv install/ install.lock
chmod 600 install.lock
搭建完成