ubuntu上安装nginx+mysql+php5-fpm(PHP5

摘要:
执行screen-sinstall,这样在断开连接后,您可以通过再次执行screen-install来恢复以前的安装界面。在我们重新启动nginx服务sudoservicenginxstart之后,我们可以访问我们的地址。看看nginx的欢迎界面是否可以出现。接下来,我们需要修改nginx的站点配置。ngnix的配置文件存储在/etc/nginx/sites-available/defaultserver{listen80;##listenripv4;thisline是默认的和简化的listen[::]:80defaultipv6only=on;##listinripv6root/usr/share/nginx/www;indexindex.phpindex.htmlindex.htm;#Makesiteaccessiblefromhttp://localhost/server_name_ ; location/{#首先尝试将请求作为文件,然后作为目录,然后返回到index.htmltry_files$uri$uri//index.html;}location/doc{root/usr/share;autoindexon;allow127.0.0.1;denyall;}#error_page404/404.html;#重定向服务器errorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{root/usr/share/nginx/www;}#proxyPHPscriptstoApachelisteningon127.0.0.1:80#location~.php${#proxy_passhttp://127.0.0.1 ;#}# 将HP脚本传递到127.0.0.1:9000#位置~上的FastCGI服务器列表。php${try_files$uri=404;#fastcgi_pass 127.0.0.1:9000;fastcgi_assunix:/var/run/php5 fpm.sock;fastcgi-index.php;includefastcgi_params;}#denyacessto。htaccess文件,如果Apache的documentroot#与nx的一个#location~/一致。ht{denyall;}}添加了一些php解析代码。

题外话:由于近段时间测试环境ssh链路质量不大好,经常短线。故我把整个安装过程放到screen里去执行,以防止断线中断了安装过程。执行screen -S install,这样断线后,只要再执行screen -r install 就可以恢复之前的安装界面。

1.安装mysql

sudo apt-get install mysql-server mysql-client
安装过程中要设置mysql root用户的密码。

2.安装nginx

sudo apt-get install nginx

3.安装成功后。我们重启下nginx服务

sudo service nginx restart
启动之后我们就可以访问一下我们的地址了。看能不能出现nginx的欢迎界面。

4.安装php5-fpm(PHP5 - FastCGI Process Manager)。

sudo apt-get install php5-fpm

5.接下来我们要修改一下nginx的站点配置了。

ngnix的配置文件存放在/etc/nginx/sites-available/default

server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
try_files $uri =404;
#fastcgi_pass 127.0.0.1:9000;
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;
}
}
增加了php解析的一些代码在里面。

6.我们在安装php5相关的一些组件。

sudo 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
7.重启服务

sudo service php5-fpm restart
sudo service nginx
8.写个探针文件试试吧。呵呵。

免责声明:文章转载自《ubuntu上安装nginx+mysql+php5-fpm(PHP5》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇自己动手添加系统调用win7下idea远程连接hadoop,运行wordCount下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

istio 学习之 手动注入sidecar

istio 创建pod的时候会给默认自动注入的命名空间 注入sidecar ,sidecar中包含envoy组件和pilot-agent组件 ,这两个共同组成sidecar。 这次的目的就是为了观察istio 注入的过程。 首先我们新创建一个test 命名空间 [root@istio-master test]# kubectl create namespa...

Nginx核心知识100讲学习笔记(陶辉)详解HTTP模块(详解11阶段)

一、server_name指令 1、指令后可跟多个域名。第一个是主域名 Syntax server_name_in_redirect on | off; Default server_name_in_redirect off; Context http, server, location server_name_in_redirect on server...

2.Nginx日常维护技巧

Nginx日常维护技巧 Nginx配置正确性检查 nginx提供了配置文件调试功能,可以快速定义配置文件存在的问题。执行如下命令检测配置文件的正确性:          [root@localhost 桌面]# which nginx /usr/local/nginx/sbin/nginx          我把nginx命令的路径写入到PATH里面,所以...

Nginx配置项优化(转载)

(1)nginx运行工作进程个数,一般设置cpu的核心或者核心数x2 如果不了解cpu的核数,可以top命令之后按1看出来,也可以查看/proc/cpuinfo文件 grep ^processor /proc/cpuinfo | wc -l  [root@lx~]# vi/usr/local/nginx1.10/conf/nginx.conf worker...

『AngularJS』$location 服务

参考: ng.$location Developer Guide: Angular Services: Using $location 简介 $location服务解析在浏览器地址栏中的URL(基于window.location)并且让URL在你的应用中可用。改变在地址栏中的URL会作用到$location服务,同样的,改变$location服务也会改...

centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节课

centos  lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress  安装phpmyadmin  定时备份mysql两种方法  第二十五节课 wordpress下载地址:https://cn.wordpress.org/ 架构:nginx代理 +LAMP 修改Windows的hosts文件 ap...