在Ubuntu 12.4 下安装 nginx, MySQL, PHP
LNMP是时下很流行的网站配置,我在配置蝉大师服务器的时候顺带把经验做个分享,蝉大师的网址是:http://www.ddashi.com/
1、第一步, 跟新apt-get
输入:
sudo apt-get update
2、第二步,安装Mysql
输入:
sudo apt-get install mysql-server php5-mysql
安装过程中mysql会要求你给数据库设定密码,输入两次后继续……
输入:
sudo mysql_install_db
继续输入:
sudo /usr/bin/mysql_secure_installation
会提示你输入刚刚设定的mysql密码,输入即可
问你是否要更改密码,输入N即可
接下来Mysql会提示几个问题,填入下边对应的y或n即可
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up...
3、第三步、安装Nginx
依次输入:
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/nginx-stable.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
sudo apt-get update
sudo apt-get install nginx
启动nginx:
sudo service nginx start
这时候你可以访问你的域名或IP地址来看看Nginx是否工作了
输入如下命令可以知道你的IP:
ifconfig eth0 | grep inet | awk '{ print $2 }'
4、第四步,安装PHP
sudo apt-get install php5-fpm
配置PHP:
sudo nano /etc/php5/fpm/php.ini
找到, cgi.fix_pathinfo=1, 把1改为0即可,如下:
cgi.fix_pathinfo=
接着:
sudo nano /etc/php5/fpm/pool.d/www.conf
找到, listen = 127.0.0.1:9000, 把 127.0.0.1:9000 改成 /var/run/php5-fpm.sock.
listen = /var/run/php5-fpm.sock
保存退出,启动PHP
sudo service php5-fpm restart
配置Nginx
sudo nano /etc/nginx/sites-available/default
启用PHP,绑定目录和index文件
[...]
server {
listen ; root /var/www;
index index.php index.html index.htm; server_name example.com; location / {
try_files $uri $uri/ /index.html;
} error_page /.html; error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
} # pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; } }
[...]
可以了,建个文件试试吧:
sudo nano /var/www/info.php
如果觉得有价值,欢迎加我微信(keerol)或关注我微博(weibo/yanghongjin)
在Ubuntu 12.4 下安装 nginx, MySQL, PHP的更多相关文章
- Angularjs学习---angularjs环境搭建,ubuntu 12.04下安装nodejs、npm和karma
1.下载angularjs 进入其官网下载:https://angularjs.org/,建议下载最新版的:https://ajax.googleapis.com/ajax/libs/angular ...
- Ubuntu 12.04 下安装 Eclipse
方法一:(缺点是安装时附加openjdk等大量程序并无法去除,优点是安装简单) $ sudo apt-get install eclipse 方法二:(优点是安装内容清爽,缺点是配置麻烦)1.安装JD ...
- Ubuntu 12.04下安装QQ 2012 Beta3(转)
Ubuntu 12.04下安装QQ 2012 Beta3 由于wine的发展非常迅速.现在网上的利用老版本的wine来安装QQ2012的教程已经有些过时了.实际上操作起来非常简单: 第一步:Ctr ...
- [转载] Ubuntu 12.04下安装git,SSH及出现的Permission denied解决办法
如何安装ssh http://os.51cto.com/art/201109/291634.htm 仅需要阅读至成功开启ssh服务即可 http://www.linuxidc.com/Linux/20 ...
- Ubuntu 12.04下安装QQ 2012 Beta3
Ubuntu 12.04下安装QQ 2012 Beta3 由于wine的发展非常迅速.现在网上的利用老版本的wine来安装QQ2012的教程已经有些过时了.实际上操作起来非常简单: 第一步:Ctr ...
- Ubuntu 12.04下安装OpenCV 2.4.2
http://sourceforge.net/projects/opencvlibrary/files/ Ubuntu 12.04下安装OpenCV 2.4.2 http://blog.csdn.ne ...
- ubuntu 12.04下安装Qt出现cannot execute binary file的解决方案
最近在ubuntu 12.04下安装QT的过程中,遇到一个问题. ./qt-opensource-linux-x64-5.7.0.run出现了bash: ./qt-opensource-linux-x ...
- Ubuntu 12.04 下安装 VirtualBox 及虚拟机winxp的安装
参考文档: http://wenku.baidu.com/view/a51ac26c9b6648d7c1c746d7.html 1.首先,先去官网(http://www.virtualbox.org) ...
- ubuntu 12.04 编译安装 nginx
下载源码包 nginx 地址:http://nginx.org/en/download.html 编译前先安装两个包: 直接编译安装会碰到缺少pcre等问题,这时候只要到再安装两个包就ok sudo ...
随机推荐
- 关于app的具体实施
鉴于我们小组做的app是关于在线做题和游戏相融合的,所以,我会先学习UI设计,毕竟好的UI设计不仅会给用户耳目一新的体验,同时还会让用户愿意去包容一些小BUG,但如果你的软件做的非常好,功能提供的很全 ...
- pandas修改列的顺序
http://www.cnblogs.com/zhoudayang/p/5414020.html cols = list(ret)cols.insert(0,cols.pop(cols.index(' ...
- sql数据库表被锁,无法查询
查看被锁表: select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName ...
- EntityFramework CodeFirst SQLServer转Oracle踩坑笔记
接着在Oracle中使用Entity Framework 6 CodeFirst这篇博文,正在将项目从SQLServer 2012转至Oracle 11g,目前为止遇到的问题在此记录下. SQL Se ...
- asp.net和js读取文件的MD5值的方法
前言 文件的md5值,即文件签名,为了验证文件的正确性,是否被恶意篡改等.每个文件有一个唯一的md5值. 最近公司开发的app文件包的校验就有用到文件md5值. 一.asp.net获取 ①和上传文件一 ...
- asp.net MVC之 自定义过滤器(Filter) - shuaixf
一.系统过滤器使用说明 1.OutputCache过滤器 OutputCache过滤器用于缓存你查询结果,这样可以提高用户体验,也可以减少查询次数.它有以下属性: Duration :缓存的时间, 以 ...
- js 简繁体字转换
有些项目需要用到简体和繁体两种字体,在js前台进行转换比较方便而且显示速度没有延时 是一个比较好的解决方案. var _isFT_CS = 0// 简体 var _isFT_CT = 1// 繁体 v ...
- C++中的全局变量、普通局部变量和静态局部变量的区别
在C++中,我们经常难以说清楚全局变量.局部变量和静态局部变量的区别.本博客从变量存储特性和标识符作用域两个角度区分这三个变量. 首先,我们来看看C++程序的内存区域是如何分配的. 从上图,我们可以看 ...
- Git ——分布式版本控制系统
Git ——分布式版本控制系统 本人git主页地址:https://github.com/lendoon/test.git git使用心得:初次接触git在课堂上,老师给我们提供了一个代码托管的场所, ...
- [SHTSC 2014] 信号增幅仪
最小覆盖圆算法.看着题解半蒙半抄的搞过去了… 主要参考以下http://blog.csdn.net/acdreamers/article/details/9406735http://blog.csdn ...