ubuntu下安装LNMP
介于网上一直说nginx在处理高连接数下的性能优势,所以非常希望尝试下。这里我们说说如何在ubuntu下安装nginx服务。
1.安装mysql
[*]sudo apt-get install mysql-server mysql-client
安装过程中要输入root用户的密码。
2.安装nginx
[*]sudo apt-get install nginx
3.安装成功后。我们重启下nginx服务
[*]sudo service nginx restart
启动之后我们就可以访问以下我们的地址了。看能不能出现nginx的欢迎界面。
4.这里我们使用php5-fpm来作为我们的php解析。
[*]sudo apt-get install php5-fpm
5.接下来我们要修改一下nginx的站点配置了。
ngnix的配置文件存放在/etc/nginx/sites-availble/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_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.写个探针文件试试吧。呵呵。。。
页:
[1]