<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } H2 { margin-bottom: 0.21cm } H2.western { font-family: "DejaVu Serif Condensed", serif } H2.cjk { font-family: "DejaVu Sans Condensed"; font-style: normal } H2.ctl { font-family: "Lohit Hindi" } H1 { margin-bottom: 0.21cm } H1.western { font-family: "DejaVu Serif Condensed", serif } H1.cjk { font-family: "DejaVu Sans Condensed"; font-size: 24pt; font-style: normal; font-weight: bold } H1.ctl { font-family: "Lohit Hindi"; font-size: 24pt; font-weight: bold } PRE.western { font-family: "DejaVu Sans Mono", monospace } PRE.cjk { font-family: "DejaVu Sans Condensed", monospace } PRE.ctl { font-family: "DejaVu Sans Mono", monospace } A:link { so-language: zxx } -->
目录
基本概念
Ubuntu 最简单的安装方法(以下仅为示例):
1. 从//192.168.0.2/test$ 下的utuntu10.10 的iso 文件下载到E 盘根目录。
2. 用winrar 把iso 文件里的wubi.exe 提取出来,放在E 盘根目录。
3. 执行wubi.exe ,把ubuntu 安装在D 盘即可。
本教程中关于“执行命令”的在“应用程序”->“ 附件”->“ 终端”中执行的。
本教程中关于“软件中心”的在“应用程序”->“Ubuntu 软件中心”。
本教程中第2-4 步为基本开发环境安装。
本教程中第5-n 步为其它环境安装。
关于Ubuntu 下的快捷键可以参看此文 http://apps.hi.baidu.com/share/detail/24544150
缩短Ubuntu 下的GRUB 启动时间
sudo vi /boot/grub/grub.cfg # 把里面的timeout=10 改成timeout=3
本机地址设置
执行命令
sudo vi /etc/network/interfaces
输入以下内容( 把xx 改成自己的ip 地址)
# The primary network interface auto eth0 iface eth0 inet static address 192.168.0.xx netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1 sudo vim /etc/resolv.conf # 输入以下两行 nameserver 8.8.8.8 nameserver 8.8.4.4
重启网络环境
sudo /etc/init.d/networking restart
安装PHP ,Nginx ,MySQL ,Memcached
[ 编辑 ] 安装PHP
在软件中心搜索“php5” 依次安装如下软件
php5 php5-curl php5-xmlrpc php5-gd php5-imagick php5-cgi php5-mysql php5-fpm php5-memcache php5-xdebug
或者直接在终端输入
sudo apt-get install php5 sudo apt-get install php5-curl sudo apt-get install php5-xmlrpc sudo apt-get install php5-gd sudo apt-get install php5-imagick sudo apt-get install php5-cgi sudo apt-get install php5-mysql sudo apt-get install php5-fpm sudo apt-get install php5-memcache sudo apt-get install php5-xdebug
或者直接输入
sudo apt-get install -y php5 php5-curl php5-xmlrpc php5-gd php5-imagick php5-cgi php5-mysql php5-fpm php5-memcache php5-xdebug
[ 编辑 ] 安装Nginx
sudo apt-get install nginx -y
[ 编辑 ] 安装MySQL
在软件中心搜索“mysql” ,安装其中的“MySQL database server” ,安装时会要求输入MySQL 的root 用户的密码,请一定要记住此密码。
[ 编辑 ] 安装Memcached 服务端
在软件中心搜索“memcached” ,安装。
[ 编辑 ] 启动各项服务
sudo /etc/init.d/php5-fpm start sudo /etc/init.d/apache2 stop # 停用系统默认的apache2 sudo /etc/init.d/nginx start sudo /etc/init.d/mysql start sudo /etc/init.d/memcached start
查看各个端口是否开放
查看80 ,9000 ,3306 ,11211 等端口开放情况
netstat -lnp
[ 编辑 ] PHP ,Nginx ,MySQL ,Memcached 详细管理命令
PHP 详细管理命令
sudo /etc/init.d/php5-fpm start sudo /etc/init.d/php5-fpm stop sudo /etc/init.d/php5-fpm restart sudo /etc/init.d/php5-fpm reload sudo /etc/init.d/php5-fpm force-reload sudo /etc/init.d/php5-fpm graceful-stop /usr/bin/php -l /work/code/dev_01/www/index.php # 分析 PHP 文件语法 /usr/bin/php -f /work/code/dev_01/www/index.php # 运行 PHP 文件
Nginx 详细管理命令
sudo /etc/init.d/nginx start sudo /etc/init.d/nginx stop sudo /etc/init.d/nginx restart sudo /etc/init.d/nginx reload sudo /etc/init.d/nginx status sudo /etc/init.d/nginx force-reload sudo /etc/init.d/nginx configtest sudo /usr/sbin/nginx -t # 测试 Nginx 配置文件是否正常
MySQL 详细管理命令
sudo /etc/init.d/mysql start sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql restart sudo /etc/init.d/mysql status sudo /etc/init.d/mysql reload sudo /etc/init.d/mysql force-reload /usr/bin/mysql -uroot -p123456 # 123456 为自己为MySQL 设置的密码。此命令可以连接到MySQL 。更多命令请参考MySQL 手册。
Memcached 详细管理命令
/etc/init.d/memcached start /etc/init.d/memcached stop /etc/init.d/memcached restart /etc/init.d/memcached status /etc/init.d/memcached force-reload
配置new.olomo.com 及local.olomo.com 测试环境
执行命令
sudo vi /etc/nginx/conf.d/olomo.conf
输入以下内容( 请把下面的/work/code/dev_01/www/ 和/work/code/dev_01/manage/ 改成自己的地址)
server { listen 80; server_name new.olomo.com union.olomo.com; charset utf-8; root /work/code/dev_01/www/; index index.php index.html index.htm; #access_log /var/log/nginx/olomo.log main; location / { if (!-f $request_filename){ rewrite ^/(.+)$ /index.php?$1& last; } } location ~ /.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name; include fastcgi_params; } location ~ //.ht { deny all; } } server { listen 80; server_name local.olomo.com; charset utf-8; root /work/code/dev_01/manage/; index index.php index.html index.htm; #access_log /var/log/nginx/olomo.log main; location / { if (!-f $request_filename){ rewrite ^/(.+)$ /index.php?$1& last; } } location ~ /.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name; include fastcgi_params; } location ~ //.ht { deny all; } }
接着执行命令
sudo /etc/init.d/nginx reload
配置hosts 映射
sudo vi /etc/hosts
输入以下几行(把192.168.0.103 换成自己本机的IP )
#google doc 74.125.227.2 docs.google.com 74.125.227.2 docs0.google.com 74.125.227.2 docs1.google.com 74.125.227.2 docs2.google.com 74.125.227.2 docs3.google.com 74.125.227.2 spreadsheets.google.com 74.125.227.2 spreadsheets0.google.com 74.125.227.2 spreadsheets1.google.com 74.125.227.2 spreadsheets2.google.com 74.125.227.2 spreadsheets3.google.com 127.0.0.1 shop_web_01 127.0.0.1 shop_web_02 127.0.0.1 shop_web_03 127.0.0.1 shop_web_04 127.0.0.1 shop_web_05 127.0.0.1 new.olomo.com 127.0.0.1 local.olomo.com 192.168.0.11 dev.olomo.com 192.168.0.11 wiki.olomo.com 192.168.0.11 bug.olomo.com 192.168.0.11 shop_database_w_01 192.168.0.11 shop_database_r_01 127.0.0.1 memcached_session_01 127.0.0.1 memcached_file_01
把网站目录(我这里是/work/code/dev_01/ )里的tmp 及data 目录的权限改成777
sudo chmod 777 -R /work/code/dev_01/tmp/ sudo chmod 777 -R /work/code/dev_01/data/