下载并安装LNMP一键安装包
wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz && tar zxf lnmp1.2-full.tar.gz && cd lnmp1.2-full && ./install.sh lnmp
如需要安装LNMPA或LAMP,将./install.sh 后面的参数替换为lnmpa或lamp即可。
按上述命令执行后,会出现如下提示:
+------------------------------------------------------------------------+ | LNMP V1.2 for Ubuntu Linux Server, Written by Licess | +------------------------------------------------------------------------+ | A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux | +------------------------------------------------------------------------+ | For more information please visit http://www.lnmp.org | +------------------------------------------------------------------------+ Please setup root password of MySQL.(Default password: root) Please enter:
需要设置MySQL的root密码(不输入直接回车将会设置为root),输入后回车进入下一步,如下图所示:
Do you want to enable or disable the InnoDB Storage Engine? Default enable,Enter your choice [Y/n]:
这里需要确认是否启用MySQL InnoDB,如果不确定是否启用可以输入 y ,输入 y 表示启用,输入 n 表示不启用。默认为y 启用,输入后回车进入下一步,选择MySQL版本:
You have 5 options for your DataBase install.
1: Install MySQL 5.1.73
2: Install MySQL 5.5.42 (Default)
3: Install MySQL 5.6.23
4: Install MariaDB 5.5.42
5: Install MariaDB 10.0.17
Enter your choice (1, 2, 3, 4 or 5):
输入MySQL或MariaDB版本的序号,回车进入下一步,选择PHP版本:
You have 5 options for your PHP install. 1: Install PHP 5.2.17 2: Install PHP 5.3.29 3: Install PHP 5.4.41 (Default) 4: Install PHP 5.5.25 5: Install PHP 5.6.9 Enter your choice (1, 2, 3, 4 or 5):
输入PHP版本的序号,回车进入下一步,选择是否安装内存优化:
You have 3 options for your Memory Allocator install. 1: Don't install Memory Allocator. (Default) 2: Install Jemalloc 3: Install TCMalloc Enter your choice (1, 2 or 3):
可以选择不安装、Jemalloc或TCmalloc,输入对应序号回车。
如果是LNMPA或LAMP的话还需要设置管理员邮箱,再选择Apache版本
提示"Press any key to install...or Press Ctrl+c to cancel"后,按回车键确认开始安装。 LNMP脚本就会自动安装编译Nginx、MySQL、PHP、phpMyAdmin、Zend Optimizer这几个软件。
============================== Check install ============================== Checking ... Nginx: OK MySQL: OK PHP: OK PHP-FPM: OK +------------------------------------------------------------------------+ | LNMP V1.2 for Ubuntu Linux Server, Written by Licess | +------------------------------------------------------------------------+ | For more information please visit http://www.lnmp.org | +------------------------------------------------------------------------+ | lnmp status manage: lnmp {start|stop|reload|restart|kill|status} | +------------------------------------------------------------------------+ | phpMyAdmin: http://IP/phpmyadmin/ | | phpinfo: http://IP/phpinfo.php | | Prober: http://IP/p.php | +------------------------------------------------------------------------+ | Add VirtualHost: lnmp vhost add | +------------------------------------------------------------------------+ | Default directory: /home/wwwroot/default | +------------------------------------------------------------------------+ | MySQL/MariaDB root password: root | +------------------------------------------------------------------------+ +-------------------------------------------+ | Manager for LNMP, Written by Licess | +-------------------------------------------+ | http://lnmp.org | +-------------------------------------------+ nginx (pid 31181 31179) is running... php-fpm is runing! * MySQL running (31504) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN
安装时间可能会几十分钟到几个小时不等,主要是机器的配置网速等原因会造成影响。
如果显示Nginx: OK,MySQL: OK,PHP: OK
并且Nginx、MySQL、PHP都是running,80和3306端口都存在,并Install lnmp V1.2 completed! enjoy it.的话,说明已经安装成功。
添加虚拟主机
执行:lnmp vhost add 出现如下界面:
root@host:~/lnmp1.2-full# lnmp vhost add +-------------------------------------------+ | Manager for LNMP, Written by Licess | +-------------------------------------------+ | http://lnmp.org | +-------------------------------------------+ Please enter domain(example: www.lnmp.org): 265android.com ====================================== Your domain: 265android.com ====================================== Do you want to add more domain name? (y/n) y Enter domain name(example: lnmp.org *.lnmp.org): www.265android.com domain list: www.265android.com Please enter the directory for the domain: 265android.com (Default directory: /home/wwwroot/265android.com): Virtual Host Directory: /home/wwwroot/265android.com =========================== Allow Rewrite rule? (y/n) =========================== y Please enter the rewrite of programme: wordpress,discuz,typecho,sablog,dabr rewrite was exist. (Default rewrite: other):wordpress =========================== You choose rewrite=wordpress =========================== =========================== Allow access_log? (y/n) =========================== n ====================================================== Create database and MySQL user with same name (y/n) ====================================================== y verify your current MySQL root password: root MySQL root password correct. Enter database name: root Your will create a database and MySQL user with same name: root Please enter password for mysql user root: root Your password: root ====================================================== Create ftp account (y/n) ====================================================== y Enter ftp account name: user Enter password for ftp account user: user Press any key to start create virtul host...
最后的信息大概是这样的
================================================ Virtualhost infomation: Your domain: 265android.com Home Directory: /home/wwwroot/265android.com Rewrite: wordpress Enable log: no Database username: root Database userpassword: root Database Name: root FTP account name: user FTP account password: user ================================================
安装wordpress
先切换到网站目录下
cd /home/wwwroot/ wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip unzip wordpress-3.9-zh_CN.zip cp -R wordpress/* /home/wwwroot/265android.com
设置目录权限
cd /home/wwwroot/265android.com chmod -R 777 wp-admin/ chmod -R 777 wp-content/ chmod -R 777 wp-includes/ chmod -R 777 wp-config-sample.php chmod -R 777 readme.html
创建数据库
在安装lnmp之后我们就已经可以通过IP打开默认网站,通过上面的phpmyadmin我们可以操作数据库(http://你的服务器ip/phpmyadmin/)
输入登录用户名和密码,默认都是root
注:mysql root之前未设置密码会导致密码为空,会登录不进去phpmyadmin,需要进入mysql把root密码设置一下
修改mysql root密码:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
dns解析
最后将a记录解析到服务器ip,然后在浏览器里面输入刚才设置域名即可开始安装,按照提示输数据库名,账号密码之后即可开始安装。
到此在VPS上用lnmp搭wordpress就完成了。
配置wordpress
打开:http://[服务器ip或者解析后的域名]/wp-admin/install.php,
注:这里显示为404,说明默认目录未改为新建的目录,需要进入ngnix修改ngnix.conf文件
nginx 修改访问home/wwwroot/default:
可以看到似乎wp-config.php文件不存在。WordPress需要这个文件方可正常工作。
需要帮助?没问题!
您可以通过我们提供的web向导来创建wp-config.php文件,但并非所有服务器都支持我们的配置向导。最安全、传统的办法是手动创建该文件。
点击创建配置文件,填入之前配置的信息
数据库名:wordpress 用户名:root 密码:root 数据库主机:localhost 表前缀:wp_android 后面就是配置站点信息了,这个是以后登录wordpress后台需要的.
由于当前wp版本是3.9,不是最新的,系统会提示更新,如果此时点击立即更新是需要输入ftp账号等信息的。
但是之前使用其他服务商的产品没有这个过程,怎么样可以省去这个步骤呢。
chattr -ais /home/wwwroot/265android.com/.user.ini chown -R www /home/wwwroot/265android.com/
现在点击下立即更新试试,不用输入ftp账号信息了吧。
参考文献:
链接:https://www.jianshu.com/p/73cddf193622