Apache安裝
到Apache官網下載httpd軟件包。網址:http://httpd./
先解壓下載到本地的httpd包
[root@info lamp]# tar -zxvf httpd-2.2.17.tar.gz
[root@info lamp]# cd httpd-2.2.17
完成httpd包解壓后,我們繼續(xù)對httpd進行編譯安裝,--enable-module=so:加載modules動態(tài)模塊。
[root@info httpd-2.2.17]# ./configure --prefix=/usr/local/apache --enable-module=so
[root@info httpd-2.2.17]# make
[root@info httpd-2.2.17]# make install
編譯安裝完成后我們可以啟動httpd服務了,現在來測試一下。
[root@info httpd-2.0.64]# /usr/local/aparche/bin/apachectl start
在瀏覽器中加載http://192.168.1.90 看到下面這句話表明我們的httpd服務已安裝成功!
It works!
PHP5安裝
到PHP官網下載PHP軟件包。網址:http://www./
解壓下載到本地的php包
[root@info lamp]# tar -zxvf php-5.2.14.tar.gz
[root@info lamp]# cd php-5.2.14
完成PHP包解壓后,我們繼續(xù)對PHP進行編譯安裝。
[root@info php-5.2.14]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/
[root@info php-5.2.14]#make
[root@info php-5.2.14]#make test
[root@info php-5.2.14]#make install
編譯安裝完后需對/usr/local/aparche/conf/httpd.conf進行配置。 [root@info php-5.2.14]# cp php.ini-development /usr/local/php/lib/php.ini
[root@info php-5.2.14]# vi /usr/local/aparche/conf/httpd.conf
#加入以下參數信息:
AddType application/x-httpd-php .php
LoadModule php5_module modules/libphp5.so
找到DirectoryIndex index.html index.html.var,在后面加上index.php 讓它把index.php做為默認頁。
將DocumentRoot "/usr/local/aparche/htdocs"web站點文件存放路徑改成你所在的Web站點路徑。
完成后重啟Apache服務
[root@info php-5.2.14]# /usr/local/apache/bin/apachectl restart
[root@info php-5.2.14]# netstat -nat|grep 80
tcp 0 0 :::80 :::* LISTEN
然后在你所在的站點下創(chuàng)建一個php文件,來測試PHP是否安裝成功。
我這邊創(chuàng)建了一個簡單的php文件,用于顯示PHP配置信息,內容
#cat /usr/loca/apach/htdocs/info.php
<?
phpinfo ();
?>
#
MySQL安裝
到mysql官網下載mysql軟件包。網址:http://www./
解壓下載到本地的php包
[root@info lamp]# tar -zxvf mysql-5.1.52.tar.gz
[root@info lamp]# cd mysql-5.1.52
對mysql進行編譯安裝
[root@info mysql-5.1.52]# mkdir /usr/local/mysql
[root@info mysql-5.1.52]# ./configure --prefix=/usr/local/mysql
[root@info mysql-5.1.52]# make
[root@info mysql-5.1.52]# make install
[root@info mysql-5.1.52]# cp support-files/my-medium.cnf /etc/my.cfg
編譯安裝完成后對mysql目錄進行權限分配,讓其它用戶無法訪問mysql目錄
[root@info mysql-5.1.52]# cd /usr/local/
[root@info local]# chgrp -R mysql mysql
[root@info local]# chown -R mysql mysql
[root@info local]# chown -R 711 mysql
[root@info local]# ls -l mysql
總用量 32
drwxr--x--x 2 mysql mysql 4096 11月 13 13:09 bin
drwxr--x--x 2 mysql mysql 4096 11月 13 13:09 docs
drwxr--x--x 3 mysql mysql 4096 11月 13 13:09 include
drwxr--x--x 3 mysql mysql 4096 11月 13 13:09 lib
drwxr--x--x 2 mysql mysql 4096 11月 13 13:10 libexec
drwxr--x--x 10 mysql mysql 4096 11月 13 13:10 mysql-test
drwxr--x--x 5 mysql mysql 4096 11月 13 13:10 share
drwxr--x--x 5 mysql mysql 4096 11月 13 13:10 sql-bench
初始化mysql授權表
[root@info local]# su - mysql
[mysql@info ~]$ /usr/local/mysql/bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password new-password
/usr/local/mysql/bin/mysqladmin -u root -h info password new-password
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
后臺啟動mysql服務
[mysql@info ~]$ /usr/local/mysql/bin/mysqld_safe &
[1] 29209
[mysql@info ~]$ 101113 13:22:05 mysqld_safe Logging to /usr/local/mysql/var/info.err.
101113 13:22:05 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
[mysql@info ~]$ ps -ef|grep mysql
root 29157 28951 0 13:21 pts/1 00:00:00 su - mysql
mysql 29158 29157 0 13:21 pts/1 00:00:00 -bash
mysql 29209 29158 0 13:22 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
mysql 29255 29209 0 13:22 pts/1 00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --log-error=/usr/local/mysql/var/info.err --pid-file=/usr/local/mysql/var/info.pid
mysql 29258 29158 0 13:22 pts/1 00:00:00 ps -ef
mysql 29259 29158 0 13:22 pts/1 00:00:00 grep mysql
[mysql@info ~]$ /usr/local/mysql/bin/mysql Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Type help; or \h for help. Type \c to clear the current input statement. mysql> show databases; mysql> quit
Bye
現在我們在瀏覽器中重新加載http://192.168.1.90/info.php頁面,查看模塊部分,發(fā)現MySQL模塊已經被加載,這表明我們已成功安裝了MySQL。 到此php整個環(huán)境基本搭建好了,希望對正在了解和學習有關這方面技術的朋友有所幫助。 |
|
來自: 離魂異客 > 《Linux Servers》