Installing LAMP

Through this tutorial, you'll learn how to Install Apache, MySQL and PHP.
If you're a webpage designer or developer and use PHP, mySQL and Apache, you'll be needing these applications to be installed. When I istalled Mint, I was looking for a way to install LAMP and found a tutorial on a website by somebody named "Cargoship". That tutorial was for ubuntu. But I installed it on my Linux mint, and it is working.
 
 
In this guide I will show you how to install a LAMP system. LAMP stands for Linux, Apache, MySQL, PHP. The guide is intended to help those who have very little knowlegde of using Linux.

We will not cover how to install Linux the L of LAMP, because Linux Mint is already installed in your computer.

Install Apache
To start off we will install Apache.
1. Open up the Terminal (Applications > Accessories > Terminal).
2. Copy/Paste or type the following line of code into Terminal and then press enter:
sudo apt-get install apache2
3. The Terminal will then ask you for you're password, type it and then press enter.

Testing Apache
To make sure everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
http://localhost/
You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you! or something like that!

Install PHP
In this part we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories > Terminal).
Step 2. Copy/Paste or type the following line into Terminal and press enter:
sudo apt-get install php5 libapache2-mod-php5
Step 3. In order for PHP to work and be compatible with Apache we must restart Apache. Type the following code in Terminal to do this:
sudo /etc/init.d/apache2 restart

Test PHP
To ensure there are no issues with PHP let's give it a quick test run.
Step 1. In the terminal copy/paste or type the following line:
sudo gedit /var/www/testphp.php
This will open up a file called testphp.php.

Step 2. Copy/Paste this line into the phptest file:

<?php phpinfo(); ?>
Step 3. Save and close the file.
Step 4. Now open you're web browser and type the following into the web address:
http://localhost/testphp.php
 
(It will show you the page that has all information about your php. If you have prior experience of installing php in some other OS, you must have seen this page.)
Congrats you have now installed both Apache and PHP!

Install MySQL
To finish this guide up we will install MySQL.
Step 1. Once again open up the amazing Terminal and then copy/paste or type this line:
sudo apt-get install mysql-server
Step 2 (optional). In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.
gksudo gedit /etc/mysql/my.cnf
Change the line
bind-address = 127.0.0.1
And change the 127.0.0.1 to your IP address.
(In Linux Mint 11, terminal itself asked to the set password, But if it doesn't follow the step 3.)
Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal:
mysql -u root
Following that copy/paste or type this line:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
(Make sure to change yourpassword to a password of your choice.)
Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste or type the following line into Terminal:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
gksudo gedit /etc/php5/apache2/php.ini
Now we are going to have to uncomment the following line by taking out the semicolon (;).
Change this line:
;extension=mysql.so
To look like this:
extension=mysql.so
Now just restart Apache and you are all set! 
sudo /etc/init.d/apache2 restart

If you get a 404 error upon visiting http://localhost/phpmyadmin: You will need to configure apache2.conf to work with Phpmyadmin.
sudo gedit /etc/apache2/apache2.conf
Include the following line at the bottom of the file, save and quit.
Include /etc/phpmyadmin/apache.conf

Then just restart Apache
sudo /etc/init.d/apache2 restart

 資料轉載:http://community.linuxmint.com/tutorial/view/486

安裝MYSQL 
如果是Linux用戶,先確定是否已安裝MySQL RPM,如果有,請將它移除:
Shell# rpm -qa|grep mysql
Shell# rpm -e mysql套件名稱
註:若有資料庫請先將它備份 

取回來的軟體通常是壓縮檔,先以root身份將軟體解壓
Shell# cd /root
Shell# gunzip < mysql-3.23.36.tar.gz | tar xvf -
( Shell# tar -zxvf mysql-3.23.36.tar.gz)

設定安裝組態
Shell# cd mysql-3.23.36
Shell# ./configure --prefix=/usr/local/mysql -with-charset=big5
(如果有其他設定方面的問題可輸入configure --help顯示設定說明。)

編譯及安裝
Shell# make
Shell# make install 

建立MySQL初始化Table
Shell# scripts/mysql_install_db
說明:建立MySQL Grant Table,第一次安裝MySQL都必須執行這個指令
複製my.cnf (my.cnf為mysql daemon起動設定檔)
Shell# cp support-files/my-medium.cnf /etc/my.cnf 

建立mysql群組以及使用者,並以mysql的身份起動server
Shell# groupadd mysql
Shell# useradd mysql -g mysql
shell# chown -R root /usr/local/mysql
Shell# chown -R mysql /usr/local/mysql/var
Shell# chgrp -R mysql /usr/local/mysql
Shell# /usr/local/mysql/bin/safe_mysqld --user=mysql & 

測試MySQL Server是不是有正常運作
Shell# /usr/local/mysql/bin/mysqladmin version
Shell# /usr/local/mysql/bin/mysqladmin variables 

8. 開機自動執行MySQL Server :修改 /etc/rc.d/rc.local,加入
/bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &' 
============================
安裝APACHE+PHP 
安裝延伸軟體(若要PHP能使用GD、Freetype等函式庫,須先它們將編譯或安裝好)
一、GD(原始檔編譯安裝)
# tar -zxvf gd.1.3.tar.gz
# cd gd.1.3
# make

二、Freetype(用rpm安裝之)
# rpm -ivh freetype-2.0.1.CLE.rpm
# rpm -ivh freetype-devel-2.0.1.CLE.rpm
注意:若系統已有上述RPM檔,可先將它們移除
如果是Linux用戶,先查看是否有安裝Apache 或PHP RPM,如果有,請將它們移除
Shell# rpm -qa|grep apache
Shell# rpm -e apache套件名稱
Shell# rpm -qa|grep php
Shell# rpm -e php套件名稱
注意:若系統有正在運作的APACHE SERVER,請先將httpd.conf備份起來 
2.先將軟體解壓縮
Shell# cd /root
Shell# gunzip < php-4.0.5.tar.gz | tar xvf -
Shell# gunzip < apache_1.3.19.tar.gz | tar xvf - 
3. 設定apache安裝目錄
Shell# cd apache_1.3.19
Shell# ./configure --prefix=/home/www 
4. 設定PHP安裝選項
Shell# cd ../php-4.0.5
Shell# ./configure \
--with-apache=../apache_1.3.19 \
--with-mysql=/usr/local/mysql \
--with-openssl --with-gd=../gd1.3 --with-ttf \
------------------------------------------------
◎ 選項--with-apache=../apache_1.3.19表示apache原始目錄
◎ --with-mysql=/usr/local/mysql表示使用mysql
◎ --with-gd=../gd1.3表示使用gd函式庫(gd1.3為gd安裝目錄)
◎ --with-openssl支援OpenSSL(需有openssl套件)
◎ --with-ttf支援freetype 
5. 編譯及安裝PHP
Shell# make
Shell# make install 
6. 編譯Apache
Shell# cd ../apache_1.3.19
Shell# ./configure --activate-module=src/modules/php4/libphp4.a
Shell# make
Shell# make install 
7. 複製PHP設定檔
Shell# cp /root/php-4.0.5/php.ini.dist /usr/local/lib/php.ini 
8. 修改Apache設定檔httpd.conf,加入或修改下列設定:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 
9. 重新啟動Apache
Shell# /home/www/bin/apachectl restart 
10. 測試
在WWW的網頁目錄下,寫一測試檔 test.php,內容為 <?php phpinfo() ? > 如可顯示php的環境內容表示 php的安裝成功了

留言

這個網誌中的熱門文章

Routeros中TX與RX的定義

RouterOS 啟用 (NAT)IP地址轉換

Windows 7 輸入法不見