English |
  • 美国VPS主机推荐
  • |
  • 代购服务
  • |
  • 10美元以下VPS
  • |
  • VPS新手指南/教程
  • |
  • 留言板
  • |
  • 关于
  • | 登录 |

    VPS初始化及Nginx+MySQL+PHP/PHPMyAdmin安装优化

    2009年03月25日 下午 | 作者:VPS侦探

    VPS购买来了,不能就这么放在,对吧。下面给大家说一下VPS买来之后的初始化操作,及Nginx+MySQL+PHP+PHPMyAdmin+eAcelerator+vsftpd这些软件的编译安装。

    一、登录VPS

    登录的方式很多,如果是Linux直接ssh就可以。

    下面以Windows下putty为例:

    putty

    填写上IP或域名,再写个名字,save ,然后Open

    1
    然后输入vps的root密码,输入的密码是不显示的!!!!!

    二、安装LNMP(基于CentOS)

    安装Nginx+MySQL+PHP+PHPMyAdmin+eAcelerator+vsftpd使用LicessLNMP

    有些VPS默认是安装Apahche的,如果安装了,请先执行:yum -y remove httpd

    LNMP已更新,新版请到https://lnmp.org/install.html 看新教程。

    下面为老旧版内容,不再适用现在。

    下面是按照的过程使用的命令,及相关注释(注释用 //,红色加粗为所使用的命令),
    Using username "root".
    root@67.215.242.196's password:
    [root@vpser ~]#cd /usr/local/src
    [root@vpser src]#ls
    [root@vpser src]#wget http://licess.googlecode.com/files/LNMP.zip      //下载LNMP文件
    --11:29:51--  http://licess.googlecode.com/files/LNMP.zip
    Resolving licess.googlecode.com... 209.85.173.82
    Connecting to licess.googlecode.com|209.85.173.82|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 11261 (11K) [application/x-zip] Saving to: `LNMP.zip'

    100%[=======================================>] 11,261      --.-K/s   in 0.1s

    11:29:52 (111 KB/s) - `LNMP.zip' saved [11261/11261] [root@vpser src]#unzip LNMP.zip        //解压LNMP压缩包
    Archive:  LNMP.zip
    creating: LNMP/
    creating: LNMP/conf/
    inflating: LNMP/conf/fcgi.conf
    inflating: LNMP/conf/nginx-load.conf
    inflating: LNMP/conf/nginx-proxy.conf
    inflating: LNMP/conf/nginx.conf
    inflating: LNMP/conf/php-fpm.conf
    inflating: LNMP/down.sh
    inflating: LNMP/install.sh
    inflating: LNMP/opt.sh
    inflating: LNMP/readme.txt
    inflating: LNMP/startup.sh
    [root@vpser src]#cd LNMP
    [root@vpser LNMP]#ls
    conf  down.sh  install.sh  opt.sh  readme.txt  startup.sh
    [root@vpser LNMP]#chmod +x install.sh down.sh        //为install.sh和down.sh添加执行权限
    [root@vpser LNMP]#./down.sh                                                   //下载安装所需的源代码文件
    =========================================================================
    LNMP v0.0.1 for VPS  Written by Licess
    =========================================================================

    For more information please visit https://lnmp.org

    start download LNMP package
    ...............................省略下载过程

    download package finished!

    =========================================================================
    [root@vpser LNMP]#clear
    [root@vpser LNMP]#ls
    conf                          mysql-5.0.22.tar.gz
    down.sh                       nginx-0.7.19.tar.gz
    eaccelerator-0.9.5.3.tar.bz2  opt.sh
    install.sh                    pcre-7.7.tar.gz
    libiconv-1.12.tar.gz          php-5.2.6-fpm-0.5.9.diff.gz
    libmcrypt-2.5.8.tar.gz        php-5.2.6.tar.gz
    mcrypt-2.6.7.tar.gz           phpMyAdmin-3.1.1-all-languages.tar.gz
    memcache-2.2.3.tgz            readme.txt
    mhash-0.9.9.tar.gz            startup.sh
    [root@vpser LNMP#]./install.sh        //开始安装
    =========================================================================
    LNMP v0.0.1 for VPS  Written by Licess
    =========================================================================
    A tool to auto-compile & install Nginx+MySQL+PHP on Linux
    For more information please visit https://lnmp.org
    The path of some dirs:
    mysql dir:   /usr/local/mysql
    php dir:     /usr/local/php
    nginx dir:   /usr/local/nginx
    web dir      /web/www

    =========================================================================

    3

    在此步中输入你要绑定的域名,例如:diavps.vpser.net  ,回车确认。
    Please input domain:
    (Default domain: www.lnmp.org):diavps.vpser.net
    ===========================
    domain=diavps.vpser.net
    ===========================

    Press any key to start...                                     \\再次按任意键确认,开始安装
    Loading "fastestmirror" plugin
    ......................................

    开始安装........

    4

    PS:屏幕疯狂的滚动.......欣赏一下

    5

    经过漫长的等待(时间不确定,根据实际情况,我的是半个多小时),终于安装完了。

    6

    下面看一下PHPInfo

    7

    PHPMyAdmin:

    8

    程序安装路径:
    MySQL :   /usr/local/mysql
    PHP :     /usr/local/php
    Nginx :   /usr/local/nginx
    PHPMyAdmin /web/www/phpmyadmin
    Web目录    /web/www

    MySQL  用户:root  密码:root

    通过下面这几个链接查看phpinfo和管理MySQL
    phpinfo    http://ip/phpinfo.php
    phpMyAdmin http://ip/phpmyadmin

    让Nginx开机后手动执行 /root/run.sh 后Nginx会运行 ,开机自动运行可以运行 LNMP目录下面的 startup.sh 文件即可。

    opt.sh 为优化文件,如果内存小于128MB可以通过执行 ./opt.sh 添加swap分区,并修改时区为东8区。注:并不一定在所有的VPS上都可以添加swap分区,swvps不可以,其他没有测试。

    安装完后,请立即修改您的MySQL的root密码,使用命令cd /usr/local/mysql/bin

    再执行:./mysqladmin -u root -p password mypasswd          //mypasswd为自己的密码

    输入这个命令后,需要输入root的原密码,然后root的密码将改为mypasswd。
    把命令里的root改为你的用户名,你就可以改你自己的密码了。

    进入phpmyadmin目录/web/www/phpmyadmin  将 config.default.php 修改为config.inc.php

    修改这个文件的 $cfg['Servers'][$i]['auth_type'] = 'http';

    $cfg['blowfish_secret'] = 'VPSER';    //VPSER为任意字符

    保存,然后就可以登录了。

    安装vsftp:
    下载vsftpd-for-LNMP.zip:执行 wget http://blog.licess.cn/uploads/200903/vsftpd-for-LNMP.zip

    unzip vsftpd-for-LNMP.zip

    cd vsftpd for LNMP

    ./installvsftpd.sh

    安装完毕后即可使用你的SSH的帐号和密码登录,也可以修改/etc/vsftpd.chroot限制用户在家目录里。默认添加了adminftp用户,但是没有设置密码,可以执行passwd adminftp 来设置密码,或者userdel admintpd 删除用户。

    执行 adduser -d /web/www/user1 -s /sbin/nologin user1  来添加一个不能SSH登录的FTP帐号,家目录为/web/www/user1 但是没有限制,添加限制,请修改/etc/vsftpd.chroot 添加要限制的用户。

    更详细的关于LNMP的可以看:https://lnmp.org

    可能在安装过程中遇到什么问题可以在下面留言。

    >>转载请注明出处:VPS侦探 本文链接地址:https://www.vpser.net/build/vps-nginx-mysql-php.html
    VPS侦探推荐:
    遨游主机VultrLinode搬瓦工LOCVPSKVMLAHOSTKVMHostXen80VPS美国VPS主机,国内推荐腾讯云阿里云
    欢迎加入VPS侦探论坛交流:https://bbs.vpser.net

    发表评论

    *必填

    *必填 (不会被公开)

    评论(24条评论)

    1. 快播电影说道:

      希望出点LNMP针对不同配置VPS的优化教程。

    2. [...] VPS初始化及 Nginx+MySQL+PHP/PHPMyAdmin安装优化 [...]

    3. j_yf说道:

      lnmp 0.3的有没有最新vsftp for lnmp
      http://blog.licess.cn/uploads/200903/vsftpd-for-LNMP.zip
      这个好像还是0.1版本的

    4. j_yf说道:

      安装vsftpd for lnmp的时候出现:

      setsebool: SELinux is disabled.
      将当前规则保存到 /etc/sysconfig/iptables: [ 确定 ]
      清除防火墙规则: [ 确定 ]
      把 chains 设置为 ACCEPT 策略:filter [ 确定 ]
      正在卸载 Iiptables 模块: [ 确定 ]
      应用 iptables 防火墙规则: [ 确定 ]
      adduser: cannot create directory /web/wwwroot
      已终止

    5. VPSer说道:

      可以修改一下脚本,将yum update的那一段去掉。

    6. j_yf说道:

      安装lnmp的时候,必须得升级centos吗?
      我安装了centos 5.2不想升级了(升级一次得四五个小时)