草庐IT

RHEL5上配置LNMP环境安装shopex

loveganen 2023-03-28 原文
 安装说明客户网站是一个使用shopex搭建的网店,现在要对客户网站做迁移,使用LNMP来搭建网站环境,客户要求尽可能使用最新的稳定版进行安装,初步打算使用nginx1.2.7+mysql5.6.10 +php5.4.13,环境搭建一切顺利,然而在最后网站安装的时候却出现了问题,由于shopex和很多同类的网店程序都需要使用zend进行数据加密,而目前的ZendOptimizer已经不支持5.3以上的php版本,只能使用5.2或者更低的版本,于是就更换php5.2.17进行安装,在安装中遇到了不少了问题,于是整理了自己的安装过程,给有类型需求的朋友提供一个案例以供参考,为简化操作配置过程中SElinux和iptables都是关闭状态的,请各位注意。

安装平台:vmware workstation 9

系统:Red Hat Enterprise Linux Server release 5.4 (Tikanga)(内核2.6.18-164.el5

内存:1024M

软件包存放位置 /usr/local/src

所用软件版本

nginx-1.2.7 mysql-5.6.10 php-5.2.17 ZendOptimizer-3.3.3 shopex4.8.5 libevent-2.1.2 libiconv-1.14所需软件包下载地址

http://nginx.org/download/nginx-1.2.7.tar.gz  http://jaist.dl.sourceforge.net/project/mysql.mirror/MySQL5.6.10/mysql-5.6.10-linux-glibc2.5-i686.tar.gz  http://mirrors.sohu.com/php/php-5.2.17.tar.gz  http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz  http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz  https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz  http://download.chinaunix.net/down.php?id=34286&ResourceID=13152&site=1一、配置安装环境

1.配置使用centos的yum源。

为了简化安装过程,一些可以使用yum进行安装的依赖包或组件我比较习惯使用yum进行安装,但红帽自带的yum源不是很好用,这里使用的是网易centos5版本的yum源。

//删除红帽系统自带的yum    # rpm -aq|grep yum | xargs rpm -e --nodeps   //下载yum安装包  # wget http://mirrors.163.com/centos/5.9/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm  # wget http://mirrors.163.com/centos/5.9/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm  # wget http://mirrors.163.com/centos/5.9/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm  //安装  # rpm -ivh yum-*  //下载163源,这里要首先保证网络和DNS解析连接正常。  # cd /etc/yum.repos.d/   # wget http://mirrors.163.com/.help/CentOS5-Base-163.repo   # sed -i "s/\$releasever/5.9/" CentOS5-Base-163.repo  //测试yum源是否可用  # yum makecache可以看到在更新yum源信息说明新的yum源已经可以正常使用了。

2.移除系统自带的rpm包的http mysql php。

# yum remove httpd mysql mysql-server php php-cli php-common php-devel php-gd  -y3.解决依赖关系。

编译安装nginx和php需要事先需要安装开发包组"Development Tools" "Development Libraries" 和"X Software Development"同时还需要专门安装pcre-devel包

# yum groupinstll "Development Tools" "Development Libraries"  "X Software Development"   # yum -y install pcre-devel4.同步系统时间。

# yum -y install ntp  # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  # vim /etc/ntp.conf  //添加下面三行内容(19行下面添加)  server 3.cn.pool.ntp.org  server 3.asia.pool.ntp.org  server 0.asia.pool.ntp.org   # /sbin/service ntpd stop //更新系统时间  #/usr/sbin/ntpdate  cn.pool.ntp.org   # /sbin/service ntpd start   # chkconfig ntpd on二、安装Nginx 

1.首先添加用户nginx,实现以之运行nginx服务进程。

# groupadd -r nginx # useradd -r -g nginx nginx2.解压进行编译安装

# cd /usr/local/src  # tar zxvf nginx-1.2.7.tar.gz  # cd nginx-1.2.7  # ./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的perl模块,可以通过为configure脚本添加--with-http_perl_module选项来实现,但目前此模块仍处于实验性使用阶段,可能会在运行中出现意外,因此,其实现方式这里不再介绍。如果想使用基于nginx的cgi功能,也可以基于FCGI来实现,具体实现方法请参照相关文档

3.为nginx提供SysV init脚本。 

新建文件/etc/rc.d/init.d/nginx,内容如下:

#!/bin/sh # # nginx - this script starts and stopsthe nginx daemon # # chkconfig:   - 85 15  # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \ #               proxy and IMAP/POP3 proxy server # processname: nginx # config:      /etc/nginx/nginx.conf # config:      /etc/sysconfig/nginx # pidfile:     /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no"] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && ./etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {   # make required directories   user=`nginx -V 2>&1 | grep "configure arguments:" | sed's/[^*]*--user=\([^ ]*\).*/\1/g' -`   options=`$nginx -V 2>&1 | grep 'configure arguments:'`   for opt in $options; do       if [ `echo $opt | grep '.*-temp-path'` ]; then            value=`echo $opt | cut -d"=" -f 2`            if [ ! -d "$value" ]; then                # echo "creating"$value                mkdir -p $value && chown-R $user $value            fi       fi   done } start() {    [ -x $nginx ] || exit 5    [ -f $NGINX_CONF_FILE ] || exit 6    make_dirs    echo -n $"Starting $prog: "    daemon $nginx -c $NGINX_CONF_FILE    retval=$?    echo    [ $retval -eq 0 ] && touch $lockfile    return $retval } stop() {    echo -n $"Stopping $prog: "    killproc $prog -QUIT    retval=$?    echo    [ $retval -eq 0 ] && rm -f $lockfile    return $retval } restart() {    configtest || return $?    stop    sleep 1    start } reload() {    configtest || return $?    echo -n $"Reloading $prog: "    killproc $nginx -HUP    RETVAL=$?    echo } force_reload() {    restart } configtest() {  $nginx -t -c $NGINX_CONF_FILE } rh_status() {    status $prog } rh_status_q() {    rh_status >/dev/null 2>&1 } case "$1" in    start)        rh_status_q && exit 0        $1        ;;    stop)        rh_status_q || exit 0        $1        ;;    restart|configtest)        $1        ;;    reload)        rh_status_q || exit 7        $1        ;;    force-reload)        force_reload         ;;    status)        rh_status        ;;    condrestart|try-restart)        rh_status_q || exit 0             ;;    *)        echo $"Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"        exit 2 esac而后为此脚本赋予执行权限

# chmod +x /etc/rc.d/init.d/nginx添加至服务管理列表,并让其开机自动启动

# chkconfig --add nginx  # chkconfig nginx on  # service nginx start而后就可以启动服务并测试了:

在浏览器输入服务器IP地址可以看到如下的欢迎界面,说明nginx已安装成功。

三、安装mysql-5.6.10

1.新建用户和数据目录。

# mkdir -pv /mydata/data  # groupadd -r mysql  # useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql  # chown -R mysql:mysql /mydata/data2.安装并初始化mysql。

# tar zxvf mysql-5.6.10-linux-glibc2.5-i6862.6-i686.tar.gz -C /usr/local  # cd /usr/local/  # ln -sv mysql-5.6.10-linux-glibc2.5-i686  mysql  # cd mysql   # chown -R mysql:mysql  .  # scripts/mysql_install_db --user=mysql --datadir=/mydata/data  # chown -R root  .3.为mysql提供主配置文件。

# cd /usr/local/mysql # cp support-files/my-default.cnf /etc/my.cnf //并修改此文件在[mysqld]字段内添加如下行指定mysql数据文件的存放位置  datadir = /mydata/data4.mysql配置sysv服务脚本

# cd /usr/local/mysql  # cp support-files/mysql.server  /etc/rc.d/init.d/mysqld //添加至服务列表  # chkconfig --add mysqld  # chkconfig mysqld on //而后就可以启动服务测试使用了。  # service mysqld start为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要进行如下步骤:

5.输出mysql的man手册至man命令的查找路径。

编辑/etc/man.config,添加如下行即可

MANPATH  /usr/local/mysql/man

添加后效果如上图。

6.输出mysql的头文件至系统头文件路径/usr/include

这可以通过简单的创建链接实现

# ln -sv /usr/local/mysql/include  /usr/include/mysql7.输出mysql的库文件给系统库查找路径。

# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf  //而后让系统重新载入系统库:  # ldconfig

8.修改PATH环境变量,让系统可以直接使用mysql的相关命令。

# echo "export PATH=$PATH:/usr/local/mysql/bin " >/etc/profile.d/mysql.sh   # source /etc/profile.d/mysql.sh四、编译安装php-5.2.17


1.解决依赖关系。

编译的php支持mcrypt、mhash扩展和libevent,需要安装如下的软件包。

# yum install libmcrypt libmcrypt-devel mcrypt mhash mhash-devel libtool-ltdl libtool-ltdl-devel -y  //安装libiconv  # cd /usr/local/src  # tar -zxvf libiconv-1.14.tar.gz  # cd libiconv-1.14  # ./configure --prefix=/usr/local  # make && make install  //安装libevent  # cd /usr/local/src  # tar zxvf libevent-2.0.21-stable.tar.gz  # cd libevent-2.0.21-stable  # ./configure  # make && make install说明:libevent是一个异步事件通知库文件,其API提供了在某文件描述上发生某事件时或其超时时执行回调函数的机制,它主要用来替换事件驱动的网络服务器上的event loop机制。目前来说, libevent支持/dev/poll、kqueue、select、poll、epoll及Solaris的event ports。

2.编译安装php-5.2.17

说明:PHP-FPM 是 一个 PHP FastCGI 进程管理器,即PHP FastCGI Progress Manager.

FastCGI是一个可伸缩的,高速地在web server和脚本语言间交互的接口。FastCGI的主要优点是把动态语言和web server分离开来。这种技术允许把web server和动态语言运行在不同的主机上,以大规模扩展和改进安全性而不损失生产效率。

php-fpm可以和任何支持远端FastCGI的web server工作。

在php-5.3.4版本之后,php-fpm已经被包含在core里边了,但

php5.2.*默认是没有php-fpm的,还需要下载一个补丁包php-5.2.17-fpm-0.5.14.diff.gz,来为php打上php-fpm的补丁。

//解压php  # tar zxvf php-5.2.17.tar.gz //为php打补丁,在php目录外执行   # gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1接下来编译安装PHP

# cd php-5.2.17  #  ./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  \ --with-config-file-scan-dir=/etc/php.d  \ --with-bz2 --with-curl  \ --with-iconv=/usr/local/  \ --enable-fastcgi \ --with-mcrypt \说明:如果前面第1步解决依赖关系时安装mcrypt相关的两个rpm包,此./configure命令可以带上--with-mcrypt选项以让php支持mycrpt扩展。--with-snmp选项则用于实现php的SNMP扩展,但此功能要求提前安装net-snmp相关软件包。

# make  # make test   # make intall3.为php提供配置文件

# cp php.ini-dist /etc/php.ini //在php.ini的配置中把(在第520行) ;cgi.fix_pathinfo=0    改为  cgi.fix_pathinfo=14.编辑php-fpm的配置文件

# vim /usr/local/php/etc/php-fpm.conf //修改如下几行(62-66行)             Unix user of processes                  <!-- <value name="user">nobody</value> -->  Unix group of processes                  <!-- <value name="group">nobody</value> -->    //去掉<!-- --> 把其中的nobody改成nginx修改后如下图

接下来就可以启动php-fpm了

# /usr/local/php/sbin/php-fpm start //使用如下命令来验正  # ps aux | grep php-fpm

看到命令输出有中几个php-fpm进程就说明启动成功了。

五、整合nginx和php5 

1.编辑/etc/nginx/nginx.conf,启用如下选项(65-71行)

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; }2.在所支持的主页面格式中添加php格式的主页,类似如下:

location /  {root   html; index  index.php index.html index.htm;}  //修改 fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  //为fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;3.而后重新载入nginx的配置文件进行测试。

# service nginx reload

在/usr/html新建index.php的测试页面,测试php是否能正常工作

# cat > /usr/html/index.php << EOF <?php phpinfo(); ?>接着就可以通过浏览器访问此测试页面了。

可以看到此时的zned版本,这个是不支持shopex安装的。

六、安装zend

# cd /usr/local/src # tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz  # cd ZendOptimizer-3.3.3-linux-glibc23-i386  # ./install会打开一个图形界面进行安装,安装过程很简单。

选ok,进入下一步

这个是类似于免责声明之类的东西,直接进入下一步

点yes进入下一步

这一步是设置zend的安装目录,使用默认即可。

这个是选择php.ini的位置,因为安装程序要修改php.ini,默认就在etc下所有不需修改

这一步要注意了,因为是一的web server是ngnix这里要选No

直接点ok进入下一步

点ok完成安装,重启一下nginx和php

# service nginx restart # /usr/local/php/sbin/php-fpm restart

再查看一下zend的版本,看到ZendOptimizer-3.3.3 的字样说明zend安装成功了。

七、安装网站测试

把下载好的网站程序上传到网站根目录,进行安装测试,安装过程很简单。默认打开时会提示一些文件和目录没有写权限,按照提示给对应的文件设置一下权限即可。我这里是已经修改过的,就直接安装了。


点同意进入下一步。

填入数据库连接,选择对应的数据库,进入下一步。

设置管理员密码,这里可以看到使用的nginx版本,点开始安装,安装过程很快。

接下来shopex会联网激活,之后就可以打开网站后台进行数据的导入了。

 小结:本文是一个基本的LNMP环境搭建,是本人安装过程的一个总结,仅供有类型需求的朋友参考考用,如发现内容有误欢迎留言指出,由于时间仓促文中一些注解没来得及添加,有不明白的可以查阅一下相关的帮助文档,我这里就不再一一说明了

有关RHEL5上配置LNMP环境安装shopex的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  5. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  6. ruby-on-rails - 独立 ruby​​ 脚本的配置文件 - 2

    我有一个在Linux服务器上运行的ruby​​脚本。它不使用rails或任何东西。它基本上是一个命令行ruby​​脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg

  7. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  8. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  9. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  10. Ruby Sinatra 配置用于生产和开发 - 2

    我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm

随机推荐