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

2,457次阅读
没有评论

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

一、登录 VPS

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

下面以 Windows 下 putty 为例:

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


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

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


二、安装 LNMP(基于 CentOS)

安装 Nginx+MySQL+PHP+PHPMyAdmin+eAcelerator+vsftpd 使用 Licess
LNMP


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

下面是按照的过程使用的命令,及相关注释 (注释用 //,红色加粗为所使用的命令)

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 
http://blog.licess.cn/lnmp/


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 
http://blog.licess.cn/lnmp/

The path of some dirs:
mysql dir:   /usr/local/mysql
php dir:     /usr/local/php
nginx dir:   /usr/local/nginx
web dir      /web/www


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

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


在此步中输入你要绑定的域名,例如: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
………………………………..


开始安装 ……..

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


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

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


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

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


下面看一下 PHPInfo

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


PHPMyAdmin:

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


程序安装路径:
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 的可以看:http://blog.licess.cn/lnmp/


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

正文完
 0
评论(没有评论)
验证码