ubuntu14.04 nginx php mysql_Ubuntu 14.04 配置php+nginx+mysql

数据库: sudo apt-get install mysql-server mysql-client 然后设置数据库ROOT用户的秘密,两次,确认。然后数据库安装成功 Nginx : sudo add-apt-repository ppa:nginx/stablesudo apt-get updatesudo apt-get install nginx 这个命令可以从PPA软件管理里

数据库:

sudo apt-get install mysql-server mysql-client

然后设置数据库ROOT用户的秘密,两次,确认。然后数据库安装成功

Nginx :

sudo add-apt-repository ppa:nginx/stable

sudo apt-get update

sudo apt-get install nginx

这个命令可以从PPA软件管理里面安装最新的稳定版本的Nginx

nginx -v

可以查看到安装的版本是nginx/1.6.0

安装之后,要启动nginx

sudo service nginx start

然后在Firefox里面输入localhost 或者http://serverip(你的ip),看到welcome的字样,说明安装成功。

php-notebook-93199.html

PHP5

这里是通过PHP-FPM来让PHP5在nginx里工作,当然如果喜欢FastCGI的朋友,可以自己去弄。

sudo apt-get install php5-fpm

安装完毕, 现在来修改nginx的配置吧

sudo vi /etc/nginx/sites-available/default

如果不懂得vi,可以查些资料,vi编辑文档,需要文档777权限 (chomd 777 /etc/...) 按i 为编辑模式,ESC退出编辑模式,进入命令模式,wq退出保存,x删除某个字符,dd删除行。也可以使用gedit来编辑,注意gedit备份文件的功能

以下是某个例子:

server {

listen 80 default_server;

listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;

index index.php index.html index.htm;

# Make site accessible from http://localhost/

server_name localhost;

location / {

try_files $uri $uri/ /index.php;

}

location /doc/ {

alias /usr/share/doc/;

autoindex on;

allow 127.0.0.1;

allow ::1;

deny all;

}

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

location ~ \.php$ {

# With php5-fpm:

try_files $uri =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

location ~ /\.ht {

deny all;

}

}

然后,reload nginx:

sudo service nginx reload

测试PHP是否安装成功

sudo vi /usr/share/nginx/html/info.php

内容:

打开浏览器,查看

php-notebook-93199.html

参考文件:http://ubuntuhandbook.org/index.php/2013/10/install-nginx-php5-mysql-lemp-ubuntu-1310/

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值