背景:
阅读新闻
LNMP服务器架设(RHEL5.5)
[日期:2012-09-27] 来源:Linux社区 作者:lxw66 [字体:]
基于域名的虚拟web主机
(1)准备网站目录及测试文件
[root@localhost ~]# mkdir -p /var/www/benet
[root@localhost ~]# echo "<h1></h1>" > /var/www/benet/index.html
[root@localhost ~]# mkdir -p /var/www/accp
[root@localhost ~]# echo "<h1></h1>" > /var/www/accp/index.html
(2)调整nginx.conf 配置文件
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"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name ;
#charset koi8-r;
charset utf-8;
access_log logs/host.access.log main;
location / {
root /var/www/benet;
index index.html index.php;
}
server {
listen 80;
server_name ;
charset utf-8;
access_log logs/accp.access.log main;
location / {
root /var/www/accp;
index index.html index.php;
}
}
}
[root@localhost ~]# service nginx reload
1、安装MySQL
(1)安装Mysql
[root@localhost ~]# tar zxf mysql-5.1.55.tar.gz
[root@localhost ~]# cd mysql-5.1.55
[root@localhost mysql-5.1.55]# ./configure --prefix=/usr/local/mysql/ --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 ;make ;make install
(2)优化调整
[root@localhost mysql-5.1.55]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.1.55]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.1.55]# chmod +x /etc/init.d/mysqld
[root@localhost mysql-5.1.55]# chkconfig --add mysqld
[root@localhost mysql-5.1.55]# ln -s /usr/local/mysql/bin/* /usr/local/bin
[root@localhost mysql-5.1.55]# ln -s /usr/local/mysql/lib/mysql/* /usr/lib
[root@localhost mysql-5.1.55]# ln -s /usr/local/mysql/include/mysql/* /usr/include
(3)初始化数据库
[root@localhost mysql-5.1.55]# useradd -M -u 27 -s /sbin/nologin mysql
[root@localhost mysql-5.1.55]# cd /usr/local/mysql/bin/
[root@localhost mysql-5.1.55]# chown -R root.mysql /usr/local/mysql/
[root@localhost mysql-5.1.55]# chown -R mysql /usr/local/mysql/var/
(4)启动Mysql
[root@localhost mysql-5.1.55]# service mysqld start
2、安装PHP
(1)编译安装PHP
[root@localhost ~]# tar zxf php-5.3.6.tar.gz
[root@localhost ~]# cd php-5.3.6
[root@localhost php-5.3.6]# ./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 install
(2)安装后的调整
[root@localhost php-5.3.6]# cp php.ini-development /usr/local/php5/php.ini
[root@localhost php-5.3.6]# ln -s /usr/local/php5/bin/* /usr/local/bin/
[root@localhost php-5.3.6]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/
(3)安装ZendGuardLoader
[root@localhost ~]# tar zxf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
[root@localhost ~]# cd ZendGuardLoader-php-5.3-linux-glibc23-i386
[root@localhost ZendGuardLoader-php-5.3-linux-glibc23-i386]# ls
php-5.3.x README.txt
[root@localhost ZendGuardLoader-php-5.3-linux-glibc23-i386]# cd php-5.3.x/
[root@localhost php-5.3.x]# cp ZendGuardLoader.so /usr/local/php5/lib/php/
[root@localhost php-5.3.x]# vi /usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
3、配置Nginx支持php环境
(1)启动php-fpm进程
[root@localhost ~]# cd /usr/local/php5/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# vi php-fpm.conf
pid = run/php-fpm.pid
user = nginx
group = nginx
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
(2)编辑/etc/init.d/nginx,以便在启动/停止Nginx服务时将php-fpm进程也自动启动/停止
[root@localhost etc]# vi /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: xxxxx
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
PROG_FPM="/usr/local/sbin/php-fpm"
PIDF_FPM="/usr/local/php5/var/run/php-fpm.pid"
case "$1" in
start)
$PROG
$PROG_FPM
;;
stop)
kill -s QUIT $(cat $PIDF)
kill -s QUIT $(cat $PIDF_FPM)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
相关资讯 LNMP
本文评论 查看全部评论 (0)
尊重网上道德,遵守中华人民共和国的各项有关法律法规 承担一切因您的行为而直接或间接导致的民事或刑事法律责任 本站管理人员有权保留或删除其管辖留言中的任意内容 本站有权在网站内转载或引用您的评论 参与本评论即表明您已经阅读并接受上述条款
评论声明
最新资讯