ubuntu 12.0 下nginx+mysql+php 的安装
来源:互联网 发布:轩辕剑之天之痕mac 编辑:程序博客网 时间:2024/04/26 00:45
1 我们使用root账户进行安装,首先切换到root账户,输入命令:
sudo su
2 安装 MySQL 5
输入命令:
apt-get install mysql-server mysql-client
安装过程中需要设置root账户密码,系统会作以下提示:
New password for the MySQL “root” user:Repeat password for the MySQL “root” user:
3 安装 Nginx
输入命令:
apt-get install nginx
在浏览器输入你服务器地址列入 http://localhost查看nginx
是否工作。
nginx 在 Ubuntu 中默认文档根目录为 /etc/nginx,配置文件 /etc/nginx/nginx.conf
4 安装 PHP5
安装 PHP5 模块:
apt-get install php5
然后重启nginx:
/etc/init.d/nginx restart
6 修改nginx配置文件nginx.conf
#user www-data;#worker_processes 4;#pid /var/run/nginx.pid;events {worker_connections 1024;# multi_accept on;}http {### Basic Settings##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/x-javascript text/xml application/xml application/xml+rss text/javascript;### 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/*; server { listen 80;#修改的域名 server_name www.kind.com 127.0.0.1; index index.html index.htm index.php;#修改的根目录 root "/html/www/kind"; location / { if (!-e $request_filename){rewrite !^(index\.php|img|images|js|css|install|files|robots\.txt|.*\.html|.*\.jpg|.*\.css|.*\.png|.*\.JPG|.*\.js|.*\.swf|.*\.php|.*\.gif) last; rewrite ^(.*)$ /index.php/$1 last; } } location ~ \.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php;#修改的fastcgi配置文件 include "/usr/local/nginx/conf/fastcgi.conf"; }#修改的日志文件 error_log "/html/logs/localhost.error.log"; access_log "/html/logs/localhost.access.log"; }}#mail {## See sample authentication script at:## http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript# ## auth_http localhost/auth.php;## pop3_capabilities "TOP" "USER";## imap_capabilities "IMAP4rev1" "UIDPLUS";# #server {#listen localhost:110;#protocol pop3;#proxy on;#}# #server {#listen localhost:143;#protocol imap;#proxy on;#}#}
5 测试 PHP5 / 可以建立一个探针页面
vi
/html/www/kind/index.php
输入下面的内容:
<?php
phpinfo();
?>
然后打开浏览器访问 (http://www.kind.com/index.php):
你可以看到一些已经支持的模块。
6 为PHP5取得 MySQL 支持
我们需要安装 php5-mysql,先查看一下php5的模块
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 php5-ldap
7 安装完成后修改 php.ini 文件
extension_dir = "/usr/lib/php5/20090626"extension = pdo.soextension = gd.soextension = php_mysql.soextension = curl.soextension = mysqli.soextension = xsl.soextension = gd.soextension = mcrypt.soextension = pdo_sqlite.soextension = mysql.soextension = pspell.soextension = sqlite3.soextension = imageick.soextension = memcache.soextension = ps.soextension = imap.soextension = ming.soextension = recode.soextension = intl.soextension = snmp.soextension = ldap.so
完成后记得重启php, nginx
php重启:
/etc/init.d/php-fpm restart
nginx重启:
/etc/init.d/nginx restart
8 修改index.php文件添加数据库测试代码
$db = mysql_connect("localhost", "root", "root");// Make sure to include your chosen username and password during MySQL installationif (!$db) die('Could not connect' . mysql_error());echo 'Connected successfully';
如果网页中显示
Connected successfully那就大功告成了
- ubuntu 12.0 下nginx+mysql+php 的安装
- ubuntu下nginx+php+mysql+memcached+mango的安装配置
- ubuntu下nginx+Mysql+php的安装和配置
- ubuntu下nginx+Mysql+php的安装和配置
- ubuntu下的nginx+php+mysql安装配置
- Ubuntu 下 nginx , php , mysql 和 golang 的简单安装
- ubuntu下的nginx+php+mysql安装配置
- Ubuntu下安装Nginx+PHP+MySQL+FastCGI
- ubuntu下nginx+php+mysql安装配置
- ubuntu下nginx+php+mysql安装配置
- Ubuntu下安装Nginx, MySQL, PHP (LEMP)
- ubuntu下安装nginx+mysql+php-fpm
- ubuntu下的nginx+php+mysql配置
- ubuntu下的nginx+php+mysql配置
- ubuntu 12.04下安装 nginx php mysql -- 安装笔记
- UBUNTU 安装PHP+MYSQL+NGINX
- Ubuntu 安装php+mysql+nginx
- Ubuntu安装nginx+php+mysql
- iBATIS动态SQL
- J2EE学习笔记——Spring基础
- log4j入门
- N个数中第k大的元素
- linux awk命令详解
- ubuntu 12.0 下nginx+mysql+php 的安装
- oracle 创建 用户
- timus 1711.Code Names
- Ural-1044. Lucky Tickets. Easy!(简单题)
- linux网络 记住 关闭防火墙
- jQuery.extend 函数详解
- shell脚本-----按行读取文件
- Microsoft Visual Studio 2010 遇到了异常,可能是由某个扩展导致的
- JAVA设计模式笔记整理(四)