数据库: sudo apt-get install mysql-server mysql-client 然后设置数据库ROOT用户的秘密,两次,确认。然后数据库安装成功 Nginx : sudo add-apt-repository ppa:nginx/stablesudo apt-get updatesudo apt-get install nginx 这个命令可以从PPA软件管理里
数据库:
sudo apt-get install mysql-server mysql-client
然后设置数据库ROOT用户的秘密,两次,确认。然后数据库安装成功
Nginx :
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
这个命令可以从PPA软件管理里面安装最新的稳定版本的Nginx
nginx -v
可以查看到安装的版本是nginx/1.6.0
安装之后,要启动nginx
sudo service nginx start
然后在Firefox里面输入localhost 或者http://serverip(你的ip),看到welcome的字样,说明安装成功。
PHP5
这里是通过PHP-FPM来让PHP5在nginx里工作,当然如果喜欢FastCGI的朋友,可以自己去弄。
sudo apt-get install php5-fpm
安装完毕, 现在来修改nginx的配置吧
sudo vi /etc/nginx/sites-available/default
如果不懂得vi,可以查些资料,vi编辑文档,需要文档777权限 (chomd 777 /etc/...) 按i 为编辑模式,ESC退出编辑模式,进入命令模式,wq退出保存,x删除某个字符,dd删除行。也可以使用gedit来编辑,注意gedit备份文件的功能
以下是某个例子:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ /index.php;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
# With php5-fpm:
try_files $uri =404;
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;
}
}
然后,reload nginx:
sudo service nginx reload
测试PHP是否安装成功
sudo vi /usr/share/nginx/html/info.php
内容:
打开浏览器,查看
参考文件:http://ubuntuhandbook.org/index.php/2013/10/install-nginx-php5-mysql-lemp-ubuntu-1310/
本文原创发布php中文网,转载请注明出处,感谢您的尊重!