• Ubuntu 11.10 安装nginx+php5+mysql 的web服务器


      Nginx是一款有俄罗斯人开发的轻量级的web 服务器软件,现在很多网站都在使用这款软件,包括国内的互联网巨头腾讯网站都在使用Nginx。这款软件优点,免费、开源、高性能,而且稳定、功能强大、配置简单、资源消耗小。通过 PHP-FPM在ubuntu 11.04中支持 php5和mysql。

      好了,不多说了,现在开始安装。

      1.初步说明

      在本教程中使用的主机名为 server1.example.com ,IP地址 192.168.0.100 。你的设置会不一样,所以你必须在适当情况下更换。

      首先所有的步骤使用root,先切换到root用户,终端输入命令:

      sudo su

      2.安装MySQL 5.0,在终端输入:

      apt-get install mysql-server mysql-client

      安装过程中会让你输入根用户密码两次。

      3.安装Nginx

      apt-get install nginx

      启动nginx命令:

      /etc/init.d/nginx start

      如果你的IP是192.168.0.100在终端输入查看nginx是否正常运行.

      提示:在ubuntu11.04中nginx 默认网站目录为

      /usr/share/nginx/www

      4.安装PHP5

      apt-get install php5-fpm

      PHP – FPM是一个守护进程(与初始化脚本 / etc/init.d/php5-fpm )运行FastCGI服务器上的端口 9000 。

      5.nginx的配置

      配置文件/etc/nginx/nginx.conf

      vi /etc/nginx/nginx.conf

      你可以通过http://wiki.codemongers.com/NginxFullExamplehttp://wiki.codemongers.com/NginxFullExample2网址了解更多配置信息。

      增加工作进程,可选,可以不修改

      worker_processes 5;

      keepalive_timeout 2;

      默认虚拟主机配置文件地址/etc/nginx/sites-available/default

      vi /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;

      }

      location /images {

      root /usr/share;

      autoindex off;

      }

      #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$ {

      fastcgi_pass 127.0.0.1:9000;

      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;

      }

      }

      稍微有点经验的同学都可以看的懂里面需要修改的信息

      现在保存文件并重新启动nginx的:

      /etc/init.d/nginx restart

      你可以建立一个探针文件,试一试php是否正常运行。

      vi /usr/share/nginx/www/info.php

      在浏览器输入地址查看,例如:http://192.168.0.100/info.php

      6.让PHP5获得MySQL支持,需要一个模块

      apt-cache search php5

      安装软件:

      apt-get install php5-mysql php5-curl php5-gd php5-idn 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

      现在重新启动PHP-FPM:

      /etc/init.d/php5-fpm restart

      现在浏览器刷新一下:http://192.168.0.100/info.php

      看看是否已经支持安装的模块。

  • 相关阅读:
    xcode
    2020上班第一天
    动态网页爬取方法
    静态网页爬虫获取数据的简单方法Xpath
    帆软9.0升级10.0(摘自帆软官方文档)
    linux下安装redis
    linux 命令笔记
    shell 编写mongodb linux下安装脚本
    pl/sql基础之三
    plsql基础二之集合
  • 原文地址:https://www.cnblogs.com/kuyuecs/p/2241170.html
Copyright © 2020-2023  润新知