Tag: Ubuntu

  • Linux/Ubuntu 10.04 + Nginx + MySql + php(FastCGI) + Phpmyadmin + WordPress

    新到手一台VPS,小试一下感觉不错,发帖留念。
    注:
    1、本文为完成之后根据回忆写成,如有问题欢迎指正
    2、大部分文本操作直接在CLI下通过shell完成

    0、准备工作
    [shell]sudo apt-get update[/shell]

    1、安装并开启Nginx
    [shell]sudo apt-get intsall nginx
    sudo /etc/init.d/nginx start
    #此时访问localhost如出现”Welcome to Nginx!”页面则表明安装成功[/shell]

    2、安装mysql(会提示设置数据库密码)
    [shell]sudo apt-get install mysql-server mysql-client[/shell]

    3、安装phpmyadmin并在虚拟主机根目录下建立软链接
    [shell]sudo apt-get install phpmyadmin
    sudo ln -s /usr/share/phpmyadmin/ /var/www/heaptech.com/ #/var/www/heaptech.com 即为虚拟主机位置[/shell]

    4、安装php
    [shell]sudo apt-get install php5 php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl[/shell]

    5、安装spawn-fcgi(控制php5-cgi的)
    [shell]sudo apt-get install spawn-fcgi[/shell]

    6、在Nginx中配置spawn-fcgi
    [shell]#在/etc/nginx/fastcgi_params文件最后添加”fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;”
    sudo sed -i ‘$ i fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;’ /etc/nginx/fastcgi_params[/shell]

    7、修改php-cgi的配置文件,把cgi.fix_pathinfo设置为1
    [shell]sudo sed -i ‘/cgi.fix_pathinfo=/ c cgi.fix_pathinfo=1;’ /etc/php5/cgi/php.ini[/shell]

    8、开启fastcgi并设置开机启动
    [shell]#1)开启
    sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid[/shell]
    [shell]#2)设置开机启动,即在/etc/rc.local中添加”/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid”
    sudo sed -i ‘/^exit/ i /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid’ /etc/rc.local[/shell]

    9、设置Nginx中虚拟主机配置(最重要的部分)
    [shell]#1)建立一个虚拟主机配置文件
    sudo vim /etc/nginx/sites-available/heaptech.com #文件名任意[/shell]
    [shell]#2)添加下方到内容
    server {
    listen 80; #WordPress的访问端口(默认80)
    server_name heaptech.com www.heaptech.com; #主机名称,绑定的域名
    root /var/www/heaptech.com; #虚拟主机根目录

    location / {
    index index.php;
    }

    location ~ .php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    }
    }[/shell]
    [shell]#3)软链接至sites-enabled文件夹
    sudo ln -s /etc/nginx/sites-available/heaptech.com /etc/nginx/sites-enabled/[/shell]

    10、安装wordpress
    [shell]cd /var/www/heaptech.com #虚拟主机根目录
    sudo wget http://wordpress.org/latest.tar.gz
    sudo tar -zxvf latest.tar.gz
    sudo mv wordpress/* .
    sudo chmod -R 755 wp-content/ #权限问题还有一点不是很明白,欢迎指教(怎样最安全?)
    sudo cp wp-config-sample.php wp-config.php
    sudo sed -i -e ‘s/database_name_here/数据库名称/’ -e ‘s/username_here/数据库用户名/’ -e ‘s/password_here/数据库密码/’ -e ‘s/localhost/主机名称/’ -e ‘$ i define(‘WP_POST_REVISIONS’, false);’ wp-config.php #需将命令中的中文替换为对应值[/shell]

    11、Last but not least
    [shell]sudo /etc/init.d/nginx restart
    #至此,所有安装工作全部完成
    #http://heaptech.com即为blog地址
    #http://heaptech.com/phpmyadmin/为phpmyadmin[/shell]

  • 颓废+悲剧

    其实考完试之后没什么紧急的事,于是便想着消遣两天顺便整一整电脑,可以是都杯具了,唯一的进展就是没有进展……
    先在这里做个小结,主要是两件事情:

    1、多系统启动U盘
    那个16G的优盘一直利用率很低,于是便想着是否可以做一个多系统启动优盘,初步想法是 WinPE + Linux

    首先是选择Linux的版本,路过的各位大牛推荐了很多,例如Puppy Linux,Slax Linux,Lubuntu等等好多版本,只是我可能还是比较喜欢Ubuntu下GNOME的样子……

    其次是引导方式的选择,网上有不少grub4dos的教程,只是我不太喜欢那种有点山寨的东西。Grub的也有,但是现在最新的版本是Grub2,所以准备自己先尝试一下,只是可惜没能成功,还在查找问题中……

    2、本机安装多系统
    此前机器是Win 7 + Ubuntu,最近神使鬼差的想整一个黑苹果玩玩,设想是Win 7 + Ubuntu 10.04 + Mac 10.6 ,很好很强大的说,只是又杯具了……

    网上还是有很多教程的,主要还是用了别人做好的镜像,过程也算比较傻瓜,经过一番折腾,我也进入了MAC界面,但是最杯具的事情也就此发生了——驱动问题。网上找了好久,结果都说我的网卡驱动——无解!折腾了好久,只好作罢,安心用Linux……

  • Recovering Ubuntu 9.10 After Installing Windows 7

    【Foreword】

    前些日子win 7离奇中毒,开机巨慢,几乎所有应用程序无法打开,只好重装。如此一来Ubuntu 9.10的Grub启动没了,由于win 7和ubuntu 9.10都是比较新的东东,网上的解决方案不多或者不是很完美(个人意见),不是需要Ubuntu live CD,就是把grub装到了mbr当中,鄙人用了一个一般笨的方法,还算比较完美的解决了……

    【Procedure】

    1)Download the file here and extract them to the directory you installed windows 7 for example ‘c:/’.

    I pick it from here

    2)Reboot the computer & choose Ubuntu 9 when it comes to mbr selection.

    3)Open the terminal and reinstall the grub2 with the following commands.

    [bash]sudo apt-get remove grub-pc
    sudo apt-get install grub-pc[/bash]
    [bash]#这里附上yuki大牛推荐的更正宗的方法:
    #把grub安装到sda的mbr
    sudo grub-install /dev/sda
    #检测其他操作系统,XP Win7等
    sudo os-prober
    #更新grub的各个启动项
    sudo update-grub
    #REBOOT
    sudo reboot[/bash]

    4)Reboot the computer & choose to enter win 7.

    5)Delete the files you established in Step 1.

    6)Now everything is the same as before.

    P.S. if there still exists some problems, please feel free to contact me.