zoukankan      html  css  js  c++  java
  • LNAMP服务器环境搭建(手动编译安装)

    LNAMP服务器环境搭建(手动编译安装)

    一、准备材料

    阿里云主机一台,操作系统CentOS 6.5 64

    lnamp.zip包(包含搭建环境所需要的所有软件)

    http://123.56.144.36:8001/tools/lnamp.zip

    二、确认环境

    #确认CentOS YUM安装使用正常

    yum clean all

    yum makecache

    #确认c gc gc-c++安装正常

    yum install -y gc gcc gcc-c++

    #确认安装环境需要的软件

    yum install -y wget zip unzip gzip

    yum install -y libxml2 libxml2-devel

    yum install -y zlib zlib-devel

    yum install -y freetype freetype-devel

    yum install -y autoconf

    yum install -y apr apr-util apr-devel apr-util-devel

    yum install -y libmcrypt libmcrypt-devel

    yum install -y libpng libpng-devel

    yum install -y libjpeg libjpeg-devel

    yum install -y turbojpeg turbojpeg-devel

    yum install -y openjpeg openjpeg-devel openjpeg-libs

    yum install -y glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel

    yum install -y curl curl-devel

    yum install -y gd gd-devel

    yum install -y make

    yum install -y ncurses ncurses-devel

    yum install -y e2fsprogs e2fsprogs-devel

    yum install -y libidn libidn-devel

    yum install -y openldap openldap-devel nss_ldap openldap-clients openldap-servers

    #yum install -y krb5*

    yum install -y openssl*

    三、安装配置服务器软件

    #使用root用户登录系统,下载软件:

    cd /root

    wget http://123.56.144.36:8001/tools/lnamp.zip

    unzip lnamp.zip

    1. 安装nginx 1.4.7

    cd /root/server/nginx-1.4.7

    ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/root/server/pcre-8.35 --with-http_realip_module --with-http_image_filter_module --with-zlib=/root/server/zlib-1.2.3

    make

    make install

    #启动方法(进程独占)

    /usr/local/nginx/sbin/nginx

    #直接ip地址访问(默认http 80端口)

    http://[server_ip_address]/ 

    #热重启(修改配置后)

    /usr/local/nginx/sbin/nginx -s reload

    #其他命令 

    #/usr/local/nginx/sbin/nginx -s stop, quit, reopen, reload

    2. 安装apache httpd-2.2.29

    cd /root/server/httpd-2.2.29

    ./configure --prefix=/usr/local/apache2/httpd_8001 --disable-userdir --enable-so --enable-ssl --enable-cgi --enable-deflate=shared --enable-expires=shared --enable-mods-shared=all --enable-rewrite=shared --enable-static-support --with-zlib --with-pcre --enable-modules=most

    make

    make install

    #修改配置(此处为简单修改,详细配置单独讲解)

    vi /usr/local/apache2/httpd_8001/conf/httpd.conf

    #修改端口#Listen 12.34.56.78:80为 #Listen 8001

    #修改用户和用户组#User daemon #Group daemon 为 #User www #Group www

    #启动方法

    /usr/local/apache2/httpd_8001/bin/apachectl start

    #直接ip地址访问(端口8001

    http://[server_ip_address]:8001/ 

    #重启(修改配置后)

    /usr/local/apache2/httpd_8001/bin/apachectl restart

    #其他命令 

    #/usr/local/apache2/httpd_8001/bin/apachectl start|restart|graceful|graceful-stop|stop

    #/usr/local/apache2/httpd_8001/bin/httpd -k start|restart|graceful|graceful-stop|stop

    3.安装apache模块mod_rpaf 

    #安装apache模块mod_rpafnginx后端的apache获取访客IP

    cd /root/server/mod_rpaf-0.6/

    /usr/local/apache2/httpd_8001/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

    #修改apache的配置文件

    vi /usr/local/apache2/httpd_8001/conf/httpd.conf

    #在 # 'Main' server configuration 的前面插入下面配置:

    ## Config mod_rpaf
    LoadModule rpaf_module modules/mod_rpaf-2.0.so
    <IfModule mod_rpaf.c>
        RPAFenable On
        RPAFsethostname On
        RPAFproxy_ips 127.0.0.1
        RPAFheader X-Forwarded-For
    </IfModule>

    #修改配置后重启

    /usr/local/apache2/httpd_8001/bin/apachectl restart

    4. 安装MySQL

    #YUM 安装MySQL,注意必须安装相关开发包

    yum install -y mysql mysql-devel mysql-server mysql-libs mysql-connector-java 

    #启动MySQL

    service mysqld start

    #运行MySQL配置程序,根据提示设置

    #相关配置有:设置root密码,关闭远程访问,删除测试数据库等。

    #请根据提示操作。

    /usr/bin/mysql_secure_installation

    #设置开机自动启动

    chkconfig mysqld on

    #其他命令 

    #service mysqld start | restart | stop

    5. 编译安装PHP所需的软件

    依次安装libxml2libmcryptlibltdlzliblibpngjpeg6freetypeautoconf

    【编译安装的过程中如果64位系统出错可以尝试./configure前面加上CFLAGS="-O3 -fPIC"】

    #安装 libxml2

    cd /root/server/libxml2-2.6.30

    ./configure --prefix=/usr/local/libxml2/

    make && make install

    #安装 libmcrypt

    cd /root/server/libmcrypt-2.5.8

    ./configure --prefix=/usr/local/libmcrypt/

    make && make install

    #安装 libltdl(for libmcrypt)

    cd /root/server/libmcrypt-2.5.8/libltdl

    ./configure --enable-ltdl-install

    make && make install

    #安装 zlib

    cd /root/server/zlib-1.2.3

    ./configure

    make && make install

    #安装 libpng

    cd /root/server/libpng-1.2.31

    ./configure --prefix=/usr/local/libpng/

    make && make install

    #安装 jpeg6

    mkdir /usr/local/jpeg6

    mkdir /usr/local/jpeg6/bin

    mkdir /usr/local/jpeg6/lib

    mkdir /usr/local/jpeg6/include

    mkdir -p /usr/local/jpeg6/man/man1

    cd /root/server/jpeg-6b

    ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

    make && make install

    #安装 freetype

    cd /root/server/freetype-2.3.5

    ./configure --prefix=/usr/local/freetype/

    make && make install

    #安装 autoconf

    cd /root/server/autoconf-2.61

    ./configure

    make && make install

    6. 编译安装PHP

    由于使用的是apache 模块化php安装(apache2handler),每个apache httpd server 需要对应一个php应用软件。

    各个版本安装需要安装不同的apache httpd serverapachephp一对一关系。

    这里以httpd_8001php52_8001对应安装为例,如果安装多个server多个版本支持可以重复安装第236步骤,httpd_800xphp5x_800x类似的命名方式安装。

    【编译安装的过程中如果64位系统出错可以尝试./configure前面加上CFLAGS="-O3 -fPIC"】

    编译安装php-5.2.17

    cd /root/server/php-5.2.17

    ./configure --prefix=/usr/local/php/php52_8001/ --with-config-file-path=/usr/local/php/php52_8001/etc/ --with-apxs2=/usr/local/apache2/httpd_8001/bin/apxs  --with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd --with-mcrypt=/usr/local/libmcrypt/ --enable-soap --enable-mbstring=all --enable-sockets --with-pdo_mysql --with-curl --with-zlib

    make && make install

    #配置apache2handler(for httpd_8001

    vi /usr/local/apache2/httpd_8001/conf/httpd.conf

    #在 # 'Main' server configuration 的前面插入下面配置:

    ## Config httpd to add php handler

    LoadModule php5_module        modules/libphp5.so
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps

    ##找到DirectoryIndex index.html 这一行

    #修改为 DirectoryIndex index.html index.php default.html default.php index.phtml

    #添加php配置文件

    cp /root/server/php-5.2.17/php.ini-dist /usr/local/php/php52_8001/etc/php.ini

    #修改配置后重启(PHP此刻生效)

    /usr/local/apache2/httpd_8001/bin/apachectl restart

    ## 安装ZendOptimizer 3.3.3(大量zend加密系统需要,仅支持php5.2及以下,php5.3以上使用ZendGuardLoader32位系统注意安装对应的i386文件)

    cd /root/server/ZendOptimizer-3.3.3-linux-glibc23-x86_64/

    ./install

    #如果成功运行,则按照提示进行安装,如果失败需要手动安装。

    mkdir /usr/local/php/php52_8001/zend/

    cp /root/server/ZendOptimizer-3.3.3-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/php/php52_8001/zend/

    #修改php配置文件php.ini

    vi /usr/local/php/php52_8001/etc/php.ini

    #shift+G到最后一行,插入下面配置即可

    [Zend]

    zend_extension="/usr/local/php/php52_8001/zend/ZendOptimizer.so"

    #修改配置后重启

    /usr/local/apache2/httpd_8001/bin/apachectl restart

    编译安装php-5.3.28

    1) 首先安装apache httpd-2.2.29,并设置端口为8002

    ##! 切记,由于安装过一次在./configure以前务必 make clean

    cd /root/server/httpd-2.2.29

    make clean

    ./configure --prefix=/usr/local/apache2/httpd_8002 --disable-userdir --enable-so --enable-ssl --enable-cgi --enable-deflate=shared --enable-expires=shared --enable-mods-shared=all --enable-rewrite=shared --enable-static-support --with-zlib --with-pcre --enable-modules=most

    make

    make install

    #备份原配置文件,拷贝新的配置文件

    mv /usr/local/apache2/httpd_8002/conf/httpd.conf /usr/local/apache2/httpd_8002/conf/httpd.conf.bak

    cp /usr/local/apache2/httpd_8001/conf/httpd.conf /usr/local/apache2/httpd_8002/conf/httpd.conf

    #修改httpd.conf里面的所有8001替换为8002

    vi /usr/local/apache2/httpd_8002/conf/httpd.conf

    2) 然后安装apache模块mod_rpaf

    cd /root/server/mod_rpaf-0.6/

    make clean

    /usr/local/apache2/httpd_8002/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

    3) 然后安装php-5.3.28

    cd /root/server/php-5.3.28

    make clean

    ./configure --prefix=/usr/local/php/php53_8002/ --with-config-file-path=/usr/local/php/php53_8002/etc/ --with-apxs2=/usr/local/apache2/httpd_8002/bin/apxs  --with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd --with-mcrypt=/usr/local/libmcrypt/ --enable-soap --enable-mbstring=all --enable-sockets --with-pdo_mysql --with-curl --with-zlib

    make

    make install

    #添加php配置文件

    cp /root/server/php-5.3.28/php.ini-production /usr/local/php/php53_8002/etc/php.ini

    #修改配置后启动apachePHP此刻生效)

    /usr/local/apache2/httpd_8002/bin/apachectl start

    ## 安装 ZendGuardLoader(32位系统注意安装对应的i386文件)

    mkdir /usr/local/php/php53_8002/zend/

    cp /root/server/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/php53_8002/zend/

    #修改php配置文件php.ini

    vi /usr/local/php/php53_8002/etc/php.ini

    #shift+G到最后一行,插入下面配置即可

    [Zend]

    zend_extension="/usr/local/php/php53_8002/zend/ZendGuardLoader.so"

    #修改配置后重启

    /usr/local/apache2/httpd_8002/bin/apachectl restart

    编译安装php-5.4.* and so on

    【同上面两个部分,可以自行安装……】

    7. 编译安装ProFTP

    ## 编译安装Apache like FTP Server

    cd /root/server/proftpd-1.3.5

    ./configure --prefix=/usr/local/proftpd

    make && make install

    #启动proftpd

    /usr/local/proftpd/sbin/proftpd

    四、创建新用户并配置server root

    1. Linux创建新用户

    #添加用户的命令:

    useradd [your username]

    #修改密码的命令:

    passwd [your username]

    #新用户创建后位置在

    /home/[ your username]

    #我们以创建一个www用户为例讲解

    useradd www -p 12348765 -s /sbin/nologin

    # useradd www添加一个用户名为www的用户

    # -p 12348765 密码设置为12348765

    # -s /sbin/nologin 将用户的shell设置为不能登录

    #运行命令

    cd /home

    ll

    #会发现有一个www的文件夹,这就是刚创建的用户www的家目录

    #ftp登录以此用户名密码登录本机ip地址即可,根目录会被锁定在此

    2. 配置server root

    服务器设计:

    Nginx作为前端代理软件,后端apache2handlerHTTPD Server作为PHP应用服务器(其他的应用如Tomcat可以做为Java Servlet服务器)。

    MySQL独立的数据库服务软件。

    虚拟主机结构:

    www虚拟空间用户,一个用户服务多个网站。

    admin管理员用户,管理服务器操作。

    root超级管理员。

    <others…> 其他用户,可以独立安装对应的服务。

    (在www虚拟空间中手动添加网站)方法:

    1、创建网站文件夹

    cd /home/www

    su www

    mkdir <yourdomain.name>

    #使用www用户登录ftp上传网站文件到该目录

    exit

    2、*如果需要MySQL数据库

    使用phpmyadmin登录创建需要的数据库,并导入数据(库)表

    http://123.56.144.36:8001/phpmyadmin/

    admin ****PWD****

    3、Apache虚拟主机配置

    cd /usr/local/apache2/httpd_8001/conf/vhosts/

    cp cn.ln-china.www.conf <your.configure.conf> 

    #修改配置文件,指定域名、文件夹位置、log文件名等

    #就是替换掉原先配置的域名相关信息为新的域名相关信息

    #修改完成后,重启apache

    /usr/local/apache2/httpd_8001/bin/apachectl restart

    4、Nginx虚拟主机配置

    cd /usr/local/nginx/conf/vhosts/

    cp cn.ln-china.www.conf <your.configure.conf> 

    #修改配置文件,指定域名、文件夹位置、log文件名等

    #就是替换掉原先配置的域名相关信息为新的域名相关信息

    #修改完成后,重启nginx

    /usr/local/nginx/sbin/nginx –s reload

    5、然后使用<yourdomain.name>访问网站即可

    顶级域名有一个www转向的配置,二级域名不需要。

  • 相关阅读:
    win10 uwp 弹起键盘不隐藏界面元素
    win10 uwp 存放网络图片到本地
    win10 uwp 存放网络图片到本地
    sublime Text 正则替换
    sublime Text 正则替换
    win10 uwp 绘图 Line 控件使用
    win10 uwp 绘图 Line 控件使用
    AJAX 是什么?
    什么是 PHP SimpleXML?
    PHP XML DOM:DOM 是什么?
  • 原文地址:https://www.cnblogs.com/isule/p/4890292.html
Copyright © 2011-2022 走看看