Ubuntu 14.04下apt-get方法安装LNMP环境

    sudo apt-get install nginx
    sudo apt-get install php5
    sudo apt-get install php5-fpm
    sudo apt-get install mysql-server    设置root密码
    sudo apt-get install phpmyadmin    选择lighttp这里nginx不是apache2

2.在安装MySQL时会出现错误:

1.1按照官方给的解决办法依然无法解决

1.2更改ubuntu14.04源升级

vim /etc/apt/sources.list

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse

1.4执行升级命令
apt-get update

3.设置MySQL密码登陆MySQL查看

4.配置nginx支持php拷贝nginx的vhost模板
1.1:cp /etc/nginx/sites-enabled/default打开如下内容 在root位置添加index.php

1.2:fastcgi_pass 127.0.0.1:9000;方式连接不在使用sock连接
1.3:修改php.ini配置 vim /etc/php5/fpm/php.ini

1.4:使用TCP连接 vim /etc/php5/fpm/pool.d/www.conf

注释掉sock
5.从新启动服务

/etc/init.d/php5-fpm restart
/etc/init.d/nginx restart

6.在nginx的vhost目录下写一个phpinfo文件
<?php
phpinfo();
?>

7.还可以通过如下命令查看PHP5支持MySQL
apt-cache search php5
使用如下命令安装
apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
加速器也是一样
apt-get install php5-XCache
从新启动服务器
/etc/init.d/php5-fpm restart
/etc/init.d/nginx restart

LNMP安装参考如下文章

猜你喜欢

转载自www.linuxidc.com/Linux/2016-07/133683.htm