网络资源的拷贝粘贴 备份参考之用


30 January 2008

Set Up Your Own Weblog : Lamp Stack

Setup your own apache server to host your weblog free

November 1st, 2007 mysurface Posted in Beginners, mysql, Admin | Hits: 11974 |

Do you feel like you want to create your own blog? Earn some side income through blogging by putting adsense, advertlets, or some other ads? But you want to start it up free of charge, just to try it out. You may think of blogspot. Google has provided a free blog space with tools for you to start off, it does allows you to place your adsense ads on blogspot.

But blogspot have few disadvantages, firstly blogspot can't be accessed from some countries, obviously from China. Secondly, accessing to blogspot sometimes slow, and it is not so feature rich, I can't customize my blog theme easily, do not support php, limited space.

Therefore, you may feel like want to own a dedicated web server. But you want it to be free of charge. Can I get it? The answer is Yes, with few requirements.

  • You need to have a PC that can get access to the internet 24/7.
    (You are not required to have static IP)
  • You need to install Linux on that PC.
    (Okay, this is not mandatory, but the guides below will only covers on Linux.)
  • An account from http://www.no-ip.com/.
    (You can get register to any free dynamic DNS provider besides no-ip, but this post only covers for no-ip users.)
  • Download Wordpress and learn up how to blog using Wordpress.
  • Required to setup port forwarding at your router
  • Thats all you need. Lets look how to set it up step by step.

    Step 1: Install linux ( I ll suggest Ubuntu)
    Howtoforge has covered a complete web servers installation using Ubuntu 7.10. My goal is to build up a simple personal web server, I do not need all the packages that Howtoforge suggested.

    The important stuff we need is LAMP stack! LAMP stack sounds very professional, but it is actually some famous apps on Linux. Linux - Apache - Mysql and PHP, that makes up LAMP.

    apt-get install mysql-server mysql-client libmysqlclient15-dev apache2 apache2-doc apache2-utils libapache2-mod-php5 php5 php5-common php5-mysql

    After that, enable some apache additional modules

    a2enmod rewrite
    a2enmod include
    /etc/init.d/apache2 force-reload

    Fire up your internet browser and type localhost in the url text box. Try to see whether you can access Apache default web page.

    Step 2: Download and install Wordpress on your LAMP stack ready machines.
    You can easily down wordpress at wordpress.org. You just need to unzip it to /var/www, and change the folder name. for example, blog. Access the readme.html from your firefox, http://localhost/blog/readme.html. Read up the installation guide. Basically, you are requested to edit wp-config.php, create mysql user and database.

    To create user for mysql, follow the simple steps here

    mysql -u root

    You may have root password for your mysql. If that is the case, you need to add -p to specified your password.

    mysql -u root -p yourpasswd

    Next, create the user.


    mysql> GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'localhost'
    -> IDENTIFIED BY 'mysqlpasswd' WITH GRANT OPTION;
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%'
    -> IDENTIFIED BY 'mysqlpasswd' WITH GRANT OPTION;

    After that, logout mysql and login again with your new mysql user account

    mysql -u mysqluser -p

    Now, create the database:

    mysql> create database dbname;

    Last step, edit your wp-config.php in the folder accordingly. You may cp it from a sample config, wp-config-sample.php. Finally, access http://localhost/blog/wp-admin/install.php to install.

    Step 3: Register an account at no-ip, and choose a url
    Register it at http://www.no-ip.com, Login and select a sub domain from them totally free. Find Hosts/redirect at left sidebar, and click Add to choose your url.

    Step 4: Setup Port forwarding at your router
    This is a bit tricky, and its hard for me to illustrate here, because different brand of router may have different ways of setup port forwarding, you will need to check out your router's manual, or contact your router's technical support. You may try to search around the web admin pages in your router with keyword such as "port range forward", "virtual server" , etc. Remember you are required to forward port 80 to your Computer's Local Lan IP, for example, if you are using linksys, it will be look like this:

    Port forwarding on linksys wireless router

    Step 4: Start to blog and ask your friends try to access your blog over the internet.
    You can now try to login with your URL, let say if I choose mysurface.no-ip.net, I will connect to my blog with http://mysurface.no-ip.net/blog. And ask your friend try to access to verify whether have you successfully forward the port. If every things goes smooth, you may start to blog.

    Responsibilities and Caution
    You PC are now connected to the world of Internet, you are responsible to make sure your PC secure, read up web server security articles, web log analysis, how to setup firewall, intruder detection system, etc.

    Make sure you backup your mysql database, wordpress folder weekly to other places, you don't want to lose your data, if anythings happen. You may write a script to upload to your gmail.

    Automated Dynamic IP update
    Due to the fact, you are leasing dynamic IP from your ISP, your global IP may change periodically, no-ip offers a script that allow your PC to automatically sync your new global IP and your URL. You can download the script HERE.

    Summary
    It seems to be quite complicated to setup a web server for beginners. This post will served as a guideline and didn't go into very details, you may need to google it or ask around in the forums if you have stuck along the process. Have fun and wish you all the best on setting up your own dedicated Apache web server.

    As an encouragement, let me tell you one thing. Linux by Examples projects are begins with this setup.

    Morpheus: I'm trying to free your mind, Neo. But I can only show you the door. You're the one that has to walk through it.
    The Matrix, movie

    Technorati Tags: , , , ,

    No comments:

    Google