VPS上安装LAMP(Linux+Apache+MySQL+PHP)步骤_Web服务器教程

编辑Tag赚U币
教程Tag:vps添加
最近买了个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服务器教程/更新时间:2013-04-13
相关Web服务器教程