搜尋
首頁php教程php手册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/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
内容:
<?php phpinfo();
?>

打开浏览器,查看



参考文件:http://ubuntuhandbook.org/index.php/2013/10/install-nginx-php5-mysql-lemp-ubuntu-1310/

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具