本文是在VM虚拟机下面装的Debian系统下安装LNMP的教程,使用apt工具安装
添加debian第三方apt-get源
这里使用的是网易和阿里的源,编辑文件/etc/apt/sources.list,把下面的源添加进去
- 网易 163源
deb http://mirrors.163.com/debian jessie main non-free contrib
deb http://mirrors.163.com/debian jessie-proposed-updates main contrib non-free
deb-src http://mirrors.163.com/debian jessie main non-free contrib
deb-src http://mirrors.163.com/debian jessie-proposed-updates main contrib non-free - 阿里源
deb http://mirrors.163.com/debian-security jessie/updates main contrib non-free
deb-src http://mirrors.163.com/debian-security jessie/updates main contrib non-free
deb http://mirrors.aliyun.com/debian jessie main non-free contrib
deb http://mirrors.aliyun.com/debian jessie-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian jessie main non-free contrib
deb-src http://mirrors.aliyun.com/debian jessie-proposed-updates main non-free contrib
添加源之后执行以下命令:
1 | apt-get update #更新系统 |
由于是在虚拟机里面安装的系统,为了方便操作,先安装SSH服务器,用于secureCRT远程连接操作apt-get install openssh-server
配置网络
vim /etc/network/interfaces #编辑interface
1 | auto lo |
/etc/init.d/networking restart #重启网卡
安装chkconfig
安装chkconfig,可以用来检查、设置系统的各种服务,设置开启启动apt-get install chkconfig
修改时区
dpkg-reconfigure tzdata
安装Nginx
1 | apt-get install nginx #安装nginx |
安装MySQL
1 | apt-get install mysql-server #安装mysql,根据提示输入y安装,安装过程中,会跳出输入root密码的界面输入2次密码,继续自动安装 |
安装phpPHP以及组件,使PHP支持 MySQL、FastCGI模式
1 | apt-get install php5-fpm php5-cgi php5-cli php5-curl php5-mysql php5-gd libjpeg8-dev php5-imap php5-ldap php5-odbc php*-pear php5-mcrypt php5-mhash libmcrypt* libmcrypt-dev php5-common php5-idn php5-imagick php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json php5-suhosin php-apc php5-dev #安装 |
###备注
nginx默认站点目录是:/usr/share/nginx/www/
权限设置:chown www-data.www-data -R /usr/share/nginx/www/ -R
MySQL数据库目录是:/var/lib/mysql
权限设置:chown mysql.mysql -R /var/lib/mysql