怎么在Ubuntu上安装LEMP(linux/nginx/MySQL/PHP)

Posted on Jun 8, 2014

英文原帖在此:How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04

简化翻译如下

  1. 安装程序文件

运行sudo apt-get update

运行sudo apt-get install mysql-server php5-mysql nginx php5-fpm

  1. 配置MySQL

运行sudo mysql_install_db

运行sudo /usr/bin/mysql_secure_installation

  1. 配置nginx

运行sudo service nginx start

修改/etc/nginx/sites-available/default

  1. 配置PHP

修改/etc/php5/fpm/php.inicgi.fix_pathinfo=0cgi.fix_pathinfo=1

修改/etc/php5/fpm/pool.d/www.conflisten = 127.0.0.1:9000listen = /var/run/php5-fpm.sock

修改完后重启PHP:sudo service php5-fpm restart

  1. 测试PHP

新建文件/usr/share/nginx/www/info.php。内容为:<?php phpinfo(); ?>

运行sudo service nginx restart

在浏览器上访问http://localhost/info.php