Ubuntu 11.04 安装 Nginx+PHP 5+MySQL的Web服务器

Linux大全评论653 views阅读模式

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

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

1.初步说明

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

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

sudo su

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

apt-get install mysql-server mysql-client

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

Ubuntu 11.04 安装 Nginx+PHP 5+MySQL的Web服务器

3.安装Nginx
apt-get install nginx
启动nginx命令:
/etc/init.d/nginx start
如果你的IP是192.168.0.100在终端输入查看nginx是否正常运行.

Ubuntu 11.04 安装 Nginx+PHP 5+MySQL的Web服务器

提示:在Ubuntu 11.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

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

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;
#}

企鹅博客
  • 本文由 发表于 2019年10月1日 07:18:38
  • 转载请务必保留本文链接:https://www.qieseo.com/141925.html

发表评论