您现在的位置: 主页 > 上位机技术 > centos > LNMP在CentOS 5下的配置
本文所属标签:
为本文创立个标签吧:

LNMP在CentOS 5下的配置

来源:centos 网络用户发布,如有版权联系网管删除 2018-08-29 

  本文暂时做CernOS 5下LNMP的教程,因为CentOS 6目前安装使用的人不多,CentOS 6的改变较大,而且目前官方暂未给出CentOS 5升级到CentOS 6的教材。

  一、系统准备

  更新系统:

  yum update

  防火墙允许80端口通信,在/etc/sysconfig/iptables中加入:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  重启iptables:

  /etc/init.d/iptables restart

  二、安装nginx

  使用EPEL源来安装nginx,因为nginx没有在CentOS源中:

  rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

  yum update

  yum install nginx sudo

  设置启动nginx并设置为开机启动服务:

  /etc/init.d/nginx start

  chkconfig --add nginx

  chkconfig nginx on

  给Web目录加入777权限和nginx用户执行权限:

  chmod 777 /usr/share/nginx/html

  chown -R nginx /usr/share/nginx/html/

  三、安装PHP with FastCGI

  yum install php-cli php spawn-fcgi wget

  配置php-cgi启动服务项:

  mkdir /Download

  cd /Download

  wget http://www.iopenv.com/download/563-php-fastcgi-rpm.sh

  wget http://www.iopenv.com/download/562-init-php-fastcgi-rpm.sh

  mv 563-php-fastcgi-rpm.sh /usr/bin/php-fastcgi

  mv 562-init-php-fastcgi-rpm.sh /etc/init.d/php-fastcgi

  chmod +x /etc/init.d/php-fastcgi

  chkconfig --add php-fastcgi

  chkconfig php-fastcgi on

  四、配置虚拟主机

  mkdir -p /usr/share/nginx/html/www.example.com

  vi /etc/nginx/conf.d/virtual.conf

  在其末尾增加,www.example.com为您的域名:

  server {

  listen 80;

  server_name www.example.com;

  location / {

  root/usr/share/nginx/html/www.example.com;

  index index.php index.html index.htm;

  }

  error_page 404 /404.html;

  location = /404.html {

  root/usr/share/nginx/html;

  }

  error_page500 502 503 504 /50x.html;

  location = /50x.html {

  root/usr/share/nginx/html;

  }

  location ~ .php$ {

  root html/www.example.com;

  fastcgi_pass127.0.0.1:9000;

  fastcgi_index index.php;

  fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/www.example.com$fastcgi_script_name;

  include fastcgi_params;

  }

  }

  重新启动nginx:

  /etc/init.d/nginx restart

  五、安装MySQL Server

  yum install mysql-server php-mysql

  /etc/rc.d/init.d/mysqld start

  chkconfig mysqld on

  重启php:

  /etc/init.d/php-fastcgi restart

  *可选,除了php-mysql扩展外,如果想安装其他扩展,可以使用:

  yum install php-*

  六、管理LAMP服务使用

  service nginx start

  service php-fastcgi start

  service mysqld start

  *start可以替换服务对应的其他命令,比如stop。

  这样LNMP在CentOS 5下的安装就完成了。

  原文地址:http://www.iopenv.com/docs/lnmp-centos-5/



              查看评论 回复



嵌入式交流网主页 > 上位机技术 > centos > LNMP在CentOS 5下的配置
 使用 启动 安装

"LNMP在CentOS 5下的配置"的相关文章

网站地图

围观()