LAMP架构,纯文本作品
(一)Apache服務的編譯安裝
1.?查找軟件包位置
[root@localhost?~]#cd?/soft/LNS/chapter05
[root@localhost?~]#ls
2.解壓包到指定位置
[root@localhost?~]#tar?zxf?httpd-2.2.17.tar.gz?-C?/usr/src/
3.編譯安裝Apache
[root@localhost?~]#cd?/usr/src/httpd-2.2.17/
[root@localhost?~]#./configure?--prefix=/usr/local/httpd?--enable-rewrite?--enable-charset-lite?--enable-cgi?;?make?;?make?????????????????????install?;
[root@localhost?~]#ls?/usr/local/httpd/
4.優化執行路徑
[root@localhost?~]#ln?-s?/usr/local/httpd/bin/*?/usr/local/bin/
[root@localhost?~]#ls?-l?/usr/local/bin/apachectl?/usr/local/bin/httpd?
5.添加為系統服務
[root@localhost?~]#cp?/usr/local/httpd/bin/apachectl?/etc/init.d/httpd
[root@localhost?~]#vi?/etc/init.d/httpd???(添加如下三行到頁首)
#!/bin/bash
#?chkconfig:?35?85?15
#?description:?startup?for?Apache?HTTP?Server
[root@localhost?~]#chkconfig?--add?httpd
[root@localhost?~]#chkconfig?--list?httpd
[root@localhost?~]#vi?/usr/local/httpd/conf/httpd.conf?
97??ServerName?www.benet.com:80
6.檢查配置文件語法是否正確
[root@localhost?~]#apachectl?-t
[root@localhost?~]#cat?/usr/local/httpd/htdocs/index.html?
[root@localhost?~]#/etc/init.d/httpd?start
[root@localhost?~]#netstat?-anpt?|?grep?httpd
????????????????????????(二)Mysql的編譯安裝
1.查找軟件包位置
[root@localhost?~]#?cd?/soft/LNS/chapter07/
2.解壓包到指定位置
[root@localhost?chapter07]#?tar?zxf?mysql-5.1.55.tar.gz?-C?/usr/src/
3.編譯安裝Mysql
[root@localhost?chapter07]#?cd?/usr/src/mysql-5.1.55/
[root@localhost?mysql-5.1.55]#?./configure?--prefix=/usr/local/mysql?--with-charset=utf8?--with-collation=utf8_general_ci?--with-extra-charset=gbk,gb2312;?make?;?make?install?;
4.拷貝樣板到主配置文件
[root@localhost?mysql-5.1.55]#?cp?support-files/my-medium.cnf?/etc/my.cnf
5.創建運行帳號
[root@localhost?~]#?useradd?-M?-u?49?-s?/sbin/nologin?mysql
6.初始化數據庫
[root@localhost?mysql-5.1.55]#?cd?/usr/local/mysql/bin/
[root@localhost?bin]#?./mysql_install_db?--user=mysql
7.修改數據庫文件夾的屬主及屬組
[root@localhost?bin]#?chown?-R?root:mysql?/usr/local/mysql/
[root@localhost?bin]#?chown?-R?mysql?/usr/local/mysql/var/
8.優化執行路徑,程序庫路徑
[root@localhost?bin]#?ln?-s?/usr/local/mysql/bin/*?/usr/local/bin/
[root@localhost?bin]#?ln?-s?/usr/local/mysql/lib/mysql/*?/usr/lib/
[root@localhost?bin]#?ln?-s?/usr/local/mysql/include/mysql/*?/usr/include/
9.添加系統服務
[root@localhost?~]#?cd?/usr/src/mysql-5.1.55/
[root@localhost?mysql-5.1.55]#?cp?support-files/mysql.server?/etc/rc.d/init.d/mysqld
[root@localhost?mysql-5.1.55]#?chmod?+x?/etc/rc.d/init.d/mysqld?
[root@localhost?mysql-5.1.55]#?chkconfig?--add?mysqld
[root@localhost?mysql-5.1.55]#?service?mysqld?start
Starting?MySQL.????????????????????????????????????????????[確定]
[root@localhost?mysql-5.1.55]#?netstat?-anptl?|?grep?mysqld
tcp????????0??????0?0.0.0.0:3306????????????????0.0.0.0:*???????????????????LISTEN??????14016/mysqld?
10.啟動mysqld服務,為root用戶設置密碼,刪除空用戶
[root@localhost?~]#?mysqladmin?-u?root?password?"666666"
[root@localhost?~]#?mysql?-u?-p666666
Welcome?to?the?MySQL?monitor.??Commands?end?with?;?or?\g.
Your?MySQL?connection?id?is?2
Server?version:?5.1.55-log?Source?distribution
Copyright?(c)?2000,?2010,?Oracle?and/or?its?affiliates.?All?rights?reserved.
This?software?comes?with?ABSOLUTELY?NO?WARRANTY.?This?is?free?software,
and?you?are?welcome?to?modify?and?redistribute?it?under?the?GPL?v2?license
Type?'help;'?or?'\h'?for?help.?Type?'\c'?to?clear?the?current?input?statement.
mysql>?
????????????????????????????????(三)PHP的編譯安裝
一.準備工作(先查看下,有沒有安裝這個軟件)
[root@localhost?~]#?rpm?-q?php?php-cli?php-ldap?php-common?php-mysql?--nodeps
package?php?is?not?installed
package?php-cli?is?not?installed
package?php-ldap?is?not?installed
package?php-common?is?not?installed
package?php-mysql?is?not?installed
二。安裝擴展工具庫--數據加密工具libmcrypt、mhash、mcrypt
安裝libmcrypt軟件
[root@localhost?~]#?cd?/soft/LNS/chapter08/
[root@localhost?chapter08]#?tar?zxf?libmcrypt-2.5.8.tar.gz?-C?/usr/src/
[root@localhost?chapter08]#?cd?/usr/src/libmcrypt-2.5.8/
[root@localhost?libmcrypt-2.5.8]#?./configure?;?make?;?make?install?
將/usr/local/lib/libmcrypt.*?超鏈接到?/usr/lib/下
[root@localhost?libmcrypt-2.5.8]#?ln?-s?/usr/local/lib/libmcrypt.*?/usr/lib
安裝mhash
[root@localhost?~]#?cd?/soft/LNS/chapter08/
[root@localhost?chapter08]#?tar?zxf?mhash-0.9.9.9.tar.gz?-C?/usr/src/
[root@localhost?chapter08]#?cd?/usr/src/mhash-0.9.9.9/
[root@localhost?mhash-0.9.9.9]#?./configure?;?make?;?make?install?
將/usr/local/lib/libmhash*?超鏈接到/usr/lib/下
[root@localhost?mhash-0.9.9.9]#?ln?-s?/usr/local/lib/libmhash*?/usr/lib/
安裝mcrypt
[root@localhost?~]#?cd?/soft/LNS/chapter08/
[root@localhost?chapter08]#?tar?zxf?mcrypt-2.6.8.tar.gz?-C?/usr/src/
[root@localhost?chapter08]#?cd?/usr/src/mcrypt-2.6.8/
[root@localhost?mcrypt-2.6.8]#?./configure?;?make?;?make?install?
三.編譯安裝PHP
[root@localhost?~]#?cd?/soft/LNS/chapter08/
[root@localhost?chapter08]#?ls
libmcrypt-2.5.8.tar.gz??php-5.3.6.tar.gz???????????????????????????ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
mcrypt-2.6.8.tar.gz?????phpMyAdmin-2.11.11.3-all-languages.tar.gz??ZendGuardLoader.so
mhash-0.9.9.9.tar.gz????phpMyAdmin-3.3.10-all-languages.tar.gz
[root@localhost?chapter08]#?tar?zxf?php-5.3.6.tar.gz?-C?/usr/src/
[root@localhost?chapter08]#?cd?/usr/src/php-5.3.6/
[root@localhost?php-5.3.6]#?./configure?--prefix=/usr/local/php5?--with-mcrypt?--with-apxs2=/usr/local/httpd/bin/apxs?
?--with-mysql=/usr/local/mysql?--with-config-file-path=/usr/local/php5?--enable-mbstring?;?make?;?make?install?
四.安裝后的調整
[root@localhost?php-5.3.6]#?cp?/usr/src/php-5.3.6/php.ini-development?/usr/local/php5/php.ini
[root@localhost?php-5.3.6]#?vi?/usr/local/php5/php.ini
226?short_open_tag?=?On????????????????????????????修改php主配置文件,使之支持使用簡潔標志,
772?default_charset?=?"utf-8"?????????????修改默認字符集為utf-8
添加ZendGuardLoader優化模塊
1895?zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
1896?zend_loader.enable=1
五.httpd.conf配置調整,使httpd服務器支持PHP頁面解析功能
[root@localhost?~]#?vi?/usr/local/httpd/conf/httpd.conf
167?????DirectoryIndex?index.php?index.html????添加index.php
310?????AddType?application/x-httpd-php?.php????添加該行
六.編寫測試頁
[root@localhost?~]#?vi?/usr/local/httpd/htdocs/test.php
<?php
phpinfo();
?>
[root@localhost?~]#?vi?/usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect('localhost','root','666666');
if($link)?echo?"php已成功創建并連接到數據庫";
mysql_close();
?>
?
本文出自 “技術成就未來” 博客,請務必保留此出處http://jishuweiwang.blog.51cto.com/6977090/1208365
轉載于:https://blog.51cto.com/beijingdba/1417849
總結
以上是生活随笔為你收集整理的LAMP架构,纯文本作品的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用iBATIS3.0完成增删改查
- 下一篇: LVS+Keepalived负载均衡方式