Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
Deepin2014.2下使用新立得软件包管理器来安装LNMP(Linux+Nginx+Mysql+PHP5)
Apps Section
3219
views ·
6
replies ·
To
floor
Go
Iczelion
deepin
2015-03-29 22:26
Author
LNMP是一个基于Ubuntu/CentOS编写的Nginx、PHP、MySQL一键安装包。可以在VPS、独立主机上轻松的安装LNMP生产环境。
Nginx是一个小巧而高效的Linux下的Web服务器软件,是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler 站点开发的,已经在一些俄罗斯的大型网站上运行多年,相当的稳定。Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。
Mysql是一个小型关系型数据库管理系统。
PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。
这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
1.首先打开新立得软件包管理器点击搜索,输入lnmp
lnmp-install.png
右键点击标记以安装,同时还可以查看LNMP安装了哪些文件
lnmp-relations.png
点击应用,这个时候系统会新立得软件会自动下载安装lnmp环境系列软件,很快就会完成,而且每次系统升级还会升级lnmp环境到最新版本。
2.安装完成LNMP后,测试nginx,php5-fpm,mysqld是否运行
ps -e | grep nginx
ps -e | grep php
ps -e | grep mysql
lnmp-active.png
再看看浏览器,在浏览器输入127.0.0.1,如下图所示,说明安装成功:
nginx.png
3.系统文件目录
1)Nginx文件目录
Nginx根目录为: /usr/share/nginx/html
Nginx运行状态管理文件路径:/etc/init.d/nginx
Nginx配置文件:/etc/nginx/nginx.conf
Nginx默认虚拟主机设置文件: /etc/nginx/sites-available/default
2)PHP5文件目录
PHP5根目录为: /usr/share/php5
PHP5运行状态管理文件路径:/etc/init.d/php5-fpm
PHP5配置文件:/etc/php5/fpm/php.ini
3)Mysql文件目录
Mysql根目录为: /usr/share/mysql
Mysql运行状态管理文件路径:/etc/init.d/mysql
Mysql配置文件:/etc/mysql/my.cnf
4.配置 nginx
使用Vi打开配置文件/etc/nginx/nginx.conf :
vi /etc/nginx/nginx.conf
我们需要调整工作进程数设置,确保:
[...]
worker_processes 4;
keepalive_timeout 65;
[...]
Copy the Code
其他参数按个人需要配置,以下仅为参考。
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
autoindex on; #开启目录浏览功能
autoindex_exact_size off; #显示文件大概大小,单位为KB或MB
autoindex_localtime on; #显示文件时间为文件的本地服务器时间
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/* text/xml application/xml application/xml+rss tex*;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Copy the Code
默认虚拟主机设置文件 /etc/nginx/sites-available/default 按如下设置:
vi /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
#显示中文目录以及文件
charset utf-8;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#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/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
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;
}
}
Copy the Code
server_name _; 默认主机名 (当然你可以修改,例如修改为: www.example.com).
index主页这一行我们加入 index.php。
PHP 重要配置配置 location ~ \.php${} 这几行我们需要启动,反注释掉。
保存文件并重新加载 nginx 命令:
service nginx reload
如果加载失败,检查上述所有配置内容,用上面的信息替换。
5. 配置 PHP5
打开配置文件 /etc/php5/fpm/php.ini…
vi /etc/php5/fpm/php.ini
如下设置
[...]
cgi.fix_pathinfo=0
[...]
Copy the Code
重新加载 PHP-FPM:
service php5-fpm reload
现在创建一个探针文件保存在 /usr/share/nginx/html目录下
vi /usr/share/nginx/html/index.php
phpinfo();
?>
Copy the Code
浏览器下访问探针文件 (e.g. http://127.0.0.1/index.php):
php5.png
至此,LNMP就已经安装配置完成。
(注:部分内容转自
Ubuntu 14.04 LTS下安装 LNMP环境http://blog.csdn.net/black_ox/article/details/38232315)
Reply
Like 0
Favorite
View the author
All Replies
oaker
deepin
2015-03-30 18:31
#1
微博已转发。
Reply
Like 0
View the author
coldlook
deepin
2015-03-30 18:55
#2
懒啊,习惯用phpstudy 集成的。
Reply
Like 0
View the author
Iczelion
deepin
2015-03-30 20:39
#3
用新立得一键安装也比较省事啊,后面有些配置,不过也不复杂
Reply
Like 0
View the author
Iczelion
deepin
2015-03-31 02:24
#4
微博已转发。
Deepin现在使用越来越顺手,期待2015新版发布呀
Reply
Like 0
View the author
阿刀
deepin
2015-06-30 20:45
#5
It has been deleted!
hwp82316
deepin
2016-01-14 23:36
#6
为什么用新立得搜索不对lnmp啊
Reply
Like 0
View the author
xuyong
deepin
2016-01-17 04:09
#7
貌似搜不到lnmp,你是怎么搜到得?
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
Deepin 20.9 no longer works with CloudFlare
Oracle Virtual Box no longer runs
Popular Events
More
Nginx是一个小巧而高效的Linux下的Web服务器软件,是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler 站点开发的,已经在一些俄罗斯的大型网站上运行多年,相当的稳定。Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。
Mysql是一个小型关系型数据库管理系统。
PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。
这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
1.首先打开新立得软件包管理器点击搜索,输入lnmp
lnmp-install.png
右键点击标记以安装,同时还可以查看LNMP安装了哪些文件
lnmp-relations.png
点击应用,这个时候系统会新立得软件会自动下载安装lnmp环境系列软件,很快就会完成,而且每次系统升级还会升级lnmp环境到最新版本。
2.安装完成LNMP后,测试nginx,php5-fpm,mysqld是否运行
ps -e | grep nginx
ps -e | grep php
ps -e | grep mysql
lnmp-active.png
再看看浏览器,在浏览器输入127.0.0.1,如下图所示,说明安装成功:
nginx.png
3.系统文件目录
1)Nginx文件目录
Nginx根目录为: /usr/share/nginx/html
Nginx运行状态管理文件路径:/etc/init.d/nginx
Nginx配置文件:/etc/nginx/nginx.conf
Nginx默认虚拟主机设置文件: /etc/nginx/sites-available/default
2)PHP5文件目录
PHP5根目录为: /usr/share/php5
PHP5运行状态管理文件路径:/etc/init.d/php5-fpm
PHP5配置文件:/etc/php5/fpm/php.ini
3)Mysql文件目录
Mysql根目录为: /usr/share/mysql
Mysql运行状态管理文件路径:/etc/init.d/mysql
Mysql配置文件:/etc/mysql/my.cnf
4.配置 nginx
使用Vi打开配置文件/etc/nginx/nginx.conf :
vi /etc/nginx/nginx.conf
我们需要调整工作进程数设置,确保:
vi /etc/nginx/sites-available/default
index主页这一行我们加入 index.php。
PHP 重要配置配置 location ~ \.php${} 这几行我们需要启动,反注释掉。
保存文件并重新加载 nginx 命令:
service nginx reload
如果加载失败,检查上述所有配置内容,用上面的信息替换。
5. 配置 PHP5
打开配置文件 /etc/php5/fpm/php.ini…
vi /etc/php5/fpm/php.ini
如下设置
service php5-fpm reload
现在创建一个探针文件保存在 /usr/share/nginx/html目录下
vi /usr/share/nginx/html/index.php
php5.png
至此,LNMP就已经安装配置完成。
(注:部分内容转自
Ubuntu 14.04 LTS下安装 LNMP环境http://blog.csdn.net/black_ox/article/details/38232315)