ubuntu 搭建lnmp

3 篇文章 0 订阅
1,ubuntu - 14.04.1
2,ubuntu 自带php版本为5.5.9(建议安装php5.6+)
3,nginx 安装默认
4,mysql 安装默认

ubuntu 安装php5.6
- sudo add-apt-repository ppa:ondrej/php
- sudo apt-get update
- sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip php5.6-fpm php5.6-dev php5.6-json

安装完成后可以执行php -m 查看安装的module
ps aux | grep php-fpm

安装nginx:(安装默认)
- sudo apt-get install nginx
安装完成后可以执行nginx -v 查看版本
ps aux | grep nginx 

安装mysql:(安装默认)
- sudo apt-get install mysql-server mysql-client
会提示你输入root用户的密码:
输入设置的密码后,选中确定,安装完成
安装完成后可以执行:mysql -u root -p 密码
进入成功后显示mysql信息

配置nginx配置文件:(/etc/nginx/conf)
新建配置文件 default.conf 内容如下:
  server {
  listen 80;
  server_name www.test.com;
  root /home/yangshudong/xiaomi/test;
  index index.php index.html index.htm;

  error_page 404 405 /error/404.html;
  error_page 500 502 503 504 /error/50x.html;

  location / {
  try_files $uri $uri/ /index.php$is_args$args;
  }

  location ~ \.php($|/) {
  include fastcgi_params;
  fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  access_log off;
  expires 340d;
  }

  location ~ .*\.(js|css)?$ {
  access_log off;
  expires 2d;
  }

  access_log /home/work/logs/nginx/default.log;
  }

或者修改nginx 配置文件:(/etc/nginx/sites-enabled)
server {
  listen 80;
  server_name www.test.com;
  root /home/yangshudong/xiaomi/test;
  index index.php index.html index.htm;

  location / {
      try_files $uri $uri/ =404;
  }

  location ~ \.php($|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
  fastcgi_index index.php;
  include fastcgi_params;
  }

  }

操作命令:(service启动)
sudo service nginx start/stop/restart
sudo nginx -t      测试nginx
sudo nginx -s reload     平滑启动nginx

sudo service php5.6-fpm start/stop/restart
sudo service mysqld start/stop/restart

可执行文件:(脚本启动)
sudo /etc/init.d/php5.6-fpm start     (启动php)
sudo /etc/init.d/nginx start     (启动nginx)
sudo /etc/init.d/mysql start     (启动mysql)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值