您好,欢迎访问一九零五行业门户网

Ubuntu 14.04 配置php+nginx+mysql

数据库: 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/stablesudo apt-get updatesudo apt-get install nginx
这个命令可以从ppa软件管理里面安装最新的稳定版本的nginxnginx -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/
其它类似信息

推荐信息