利用源代碼搭建lamp環境

 

一.測試開發環境
[root@localhost ~]# yum grouplist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process
rhel-cluster                                              | 1.3 kB     00:00    
rhel-clusterstorage                                       | 1.3 kB     00:00    
rhel-erver                                                | 1.3 kB     00:00    
rhel-vt                                                   | 1.3 kB     00:00    
Installed Groups:
Administration Tools
   Authoring and Publishing
   Development Libraries
   Development Tools
   Editors
   FTP Server
   GNOME Desktop Environment
   GNOME Software Development
   Games and Entertainment
   Graphical Internet
   Graphics
   Legacy Network Server
   Legacy Software Development
   Legacy Software Support
   Mail Server
   Network Servers
   Office/Productivity
   Printing Support
   Server Configuration Tools
   Sound and Video
   System Tools
   Text-based Internet
   X Software Development
   X Window System
Available Groups:
   Cluster Storage
   Clustering
   DNS Name Server
   Engineering and Scientific
   Java Development
   KDE (K Desktop Environment)
   KDE Software Development
   MySQL Database
   News Server
   OpenFabrics Enterprise Distribution
   PostgreSQL Database
   Virtualization
   Web Server
   Windows File Server
Done
編譯環境由以上幾個才能編譯成功
 
源代碼安裝通常狀況下的源代碼安裝的軟件都是吧源代碼存放在/usr/local/src目錄下
源代碼安裝的內核存放在/usr/src目錄下
額外安裝的軟件(綠色軟件)原軟件存放在/usr/local/目錄下
解壓縮
[root@localhost ~]# unzip -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/
解壓縮後查看自帶的說明性文檔
[root@localhost mysql-5.5.15-linux2.6-i686]# ls
bin       data include         lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README       share    support-files
查看INSTALL-BINARY
[root@localhost mysql-5.5.15-linux2.6-i686]# less INSTALL-BINARY
 
 
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
 
   A more detailed version of the preceding description for
 
二.按照上面的步驟安裝mysql
shell> groupadd mysql     (建立組)
shell> useradd -r -g mysql mysql (建立帳號)
shell> cd /usr/local           (切換目錄)
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz    (解壓縮以前已經作過)
shell> ln -s full-path-to-mysql-VERSION-OS mysql      (建立鏈接方便之後進行操做)
shell> cd mysql                  (切換目錄)
shell> chown -R mysql .          (改變mysql目錄下文件的全部者)
shell> chgrp -R mysql .           (改變mysql目錄下文件的所屬組)
shell> scripts/mysql_install_db --user=mysql     (初始化)
shell> chown -R root .                          (把全部者再改成root)
shell> chown -R mysql data                        
# Next command is optional              (下面爲可選命令)
shell> cp support-files/my-medium.cnf /etc/my.cnf    (能夠選擇)
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysqld    (之後啓動就能夠用service啓動了)
 
建立鏈接庫文件
[root@localhost ~]# cd /etc/ld.so.conf.d/
[root@localhost ld.so.conf.d]#
[root@localhost ld.so.conf.d]# vim mysql.conf
1         /usr/local/mysql/lib (只用寫這一行就好了)
 
[root@localhost ld.so.conf.d]# ldconfig -v |grep mysql
/usr/local/mysql/lib:
         libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0    
  三.安裝apache
1.[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src
2.[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --with-z
說明: --prefix //安裝路徑
--sysconfdir //配置文件位置
--enable-so //造成動態連接庫
--enable-ssl //支持 ssl功能
--with-z //確保安裝了 zlib
3.[root@localhost httpd-2.2.19]#make //生成文件
4. [root@localhost httpd-2.2.19]#make install //把生成的文件放到相應的位置
[root@localhost ~]# cd /usr/local/apache/bin
[root@localhost bin]# ./apachectl start //執行腳本,啓動服務
[root@localhost bin]# netstat -tupln |grep 80
tcp 0 0 :::80 :::* LISTEN 29847/httpd
5.設置成爲開機啓動
vim /etc/rc.d/rc.local //開機腳本
文件內容加上:
/usr/local/apache/bin/apachectl start
6.庫文件
[root@localhost bin]# cd /etc/ld.so.conf.d
[root@localhost ld.so.conf.d]# vim httpd.conf
文件內容:
/usr/local/apache/lib
[root@localhost ld.so.conf.d]# ldconfig -v
[root@localhost ld.so.conf.d]# ldconfig -vp |grep apr
7.頭文件
[root@localhost ld.so.conf.d]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apache/include/ apache
四.安裝php
1. [root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src
[root@localhost ~]# cd /usr/local/src/php-5.3.7/
2.[root@localhost php-5.3.7]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring=all
說明: --with-apxs2=/usr/local/apache/bin/apxs //將php編譯成apache的模塊,容許apache的apxx調用該模塊
--with-mysql=/usr/local/mysql //指明 mysql的安裝位置
--with-mysqli=/usr/local/mysql/bin/mysql_config //調用 myql接口
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make install
3.cd /usr/local/apache/htdocs // apache 站點主目錄
vim index.html
mv index.html index.php
vim /etc/httpd/httpd.conf
文件內容加入 :
166 AddType application/x-httpd-php .php //apache //須要加入這句話才能處理 php頁面
168 加入 index.php
4./usr/local/apache/bin/apachectl start //啓動 apache服務
5./usr/local/mysql/bin/mysql //進入數據庫
/usr/local/mysql/bin/mysqladmin – u root –p password ‘123’ //建立賬號
相關文章
相關標籤/搜索