VPS上安裝LAMP(Linux+Apache+MySQL+PHP)步驟_Web服務器教程
最近買了個VPS,128M內存,8G硬盤,CentOS5操作系統,系統初始化后,內存使用情況如下:
total used free shared buffers cached
Mem: 131232 62872 68360 0 11384 37688
硬盤使用情況如下:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 8256952 626932 7210592 8% /
好可憐的內存,為此,只好盡量少在上面裝東西,什么ftp、什么pptp都省得裝了。只在上面裝了LAMP,分享安裝步驟如下。
先安裝基本編譯程序
yum install gcc
yum install make
下載LAMP需要用到的包
MySQL-client-community-5.1.41-0.rhel5.i386.rpm
MySQL-devel-community-5.1.41-0.rhel5.i386.rpm
MySQL-server-community-5.1.41-0.rhel5.i386.rpm
gd-2.0.35.tar.gz
httpd-2.2.14.tar.gz
libpng-1.2.41.tar.gz
libxml2-2.7.6.tar.gz
php-5.3.1.tar.gz
zlib-1.2.3.tar.gz
由于編譯mysql時不大順利,需要其他包,故沒有用源碼編譯安裝,用的是rpm安裝安
安裝Apache
./configure --prefix=/usr/local/httpd --enable-module=so --enable-rewrite
make
make install
加入啟動項,使其隨機啟動(由于沒有安裝chkconfig,所以沒有用添加服務的方式)
在/etc/rc.d/rc.local中增加啟動apache的命令,例如:/usr/local/httpd/bin/apachectl -k start
安裝PHP基本支持庫
libxml2
zlib
ligpng
gd
基本都是按如下流程編譯安裝,但注意安裝的順序:
cd source-path
./configure
make
make install
MySQL rpm包安裝
rpm -ivh MySQL-server-community-5.1.41-0.rhel5.i386.rpm #服務端
rpm -ivh MySQL-client-community-5.1.41-0.rhel5.i386.rpm #客戶端
rpm -ivh MySQL-devel-community-5.1.41-0.rhel5.i386.rpm #PHP編譯時需要用到
復制配置文件
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
編譯安裝PHP5
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-gd=/usr/local --with-mysql --with-libxml-dir --with-png-dir --with-pear=/usr/local/php/pear --enable-mbstring --with-config-file-path=/usr/local/php/ --disable-debug --enable-safe-mode
make
make install
cp php.ini-production /usr/local/php/php.ini #復制php配置文件到設定的目錄
如果不需要支持pear,可以去掉 --with-pear=/usr/local/php/pear
接下來就可以配置LAMP了,想關配置文件如下
PHP配置文件:/usr/local/php/php.ini
Apache主配置文件:/usr/local/httpd/conf/httpd.conf
MySQL配置文件:/etc/my.cnf
相關啟動命令
service mysql start|stop|restart
/usr/local/httpd/bin/apachectl -k start|stop|restart
以上如有不明或遺漏或有更好的方案,請不惜鍵盤,給我留言,謝謝。
聽說LNMP(Linux+Nginx+MySQL+PHP)比較省內存,下次想試試。
相關Web服務器教程:
- 相關鏈接:
- 教程說明:
Web服務器教程-VPS上安裝LAMP(Linux+Apache+MySQL+PHP)步驟。