编译安装LAMP平台和出现的问题
LAMP目前最为成熟的一种企业网站应用模式,可提供动态Web站点应用及开发环境构成组件Linux、Apache、MySQL、PHP/Perl/PythonLAMP的优势成本低廉可定制、易于开发方便易用、安全和稳定1.准备工作服务器IP:192.168.1.10# service iptablesstop //关闭防火墙# setenforce 0 //关闭selinux# echo "192.168.1.10 www.benet.com" >> /etc/hosts2.检查是否通过rpm方式安装了相关软件,防止冲突# rpm –qa |grep httpd httpd-manual webalizer subversionmod_python mod_ssl mod_perl system-config-httpd php php-cli php-ldap php-commonphp-mysqlmysql-server mysql dovecot --nodeps如果有相关冲突的包就要先卸载掉rpm-e phpphp-cliphp-ldap php-commonphp-mysql--nodepsyum -y insatll gcc* 安装编译的环境gcc
tar zxvf httpd-2.2.9.tar.gz -C /usr/src/
cd /usr/src/httpd-2.2.9/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite--enable-charset-lite --enable-cgi
make && make install
cd /usr/local/httpd/
ls
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
#!/bin/sh#chkconfig:345 61 61#description:Apache httpd# chmod +x /etc/init.d/httpd# chkconfig --add httpd# chkconfig --list httpdhttpd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭# service httpd restart# cd/usr/local/httpd/conf/# vi httpd.conf
chkconfig httpd on
另外一种问题可能会遇到,我列出来:
问题2:/usr/local/apache/bin/httpd: errorwhile loading shared libraries: libiconv.so.2: cannot open shared object file:No such file or directory有很多so模块在/usr/local/lib目录下,所以在/etc/ld.so.conf中加入/usr/local/lib这一行# vi/etc/ld.so.conf/usr/local/lib# /sbin/ldconfig-v现在您已经将 Apach源代码安装在/usr/local/httpd。本源代码安装支持可装载模块和标准的 MPM prefork。之后,可以使用如下命令启动 Apache 服务器:#/usr/local/httpd/bin/apachectl startApache虚拟主机配置
如果需要在一个web服务器上面跑多个web站点就需要定义虚拟主机。通过虚拟主机web服务器可以充分利用服务器硬件资源,降低网站运行成本。虚拟主机有以下三种类型:
基于IP:一个站点使用一个IP地址
基于端口:多个站点使用一个Ip地址,但是访问端口不同
基于域名:多个站点使用一个Ip地址,但是域名不同
注意:中心主机和虚拟主机无法一起使用,如果使用虚拟主机就必须取消中心主机。取消中心主机:注释中心主机的DocumentRoot即可。
虚拟主机的定义:
基于IP:HOST的写法 IP1:80 IP2:80基于端口: IP:80 IP:8080基于域名: IP:80ServerName不同
设置基于端口的虚拟主机:
cd /usr/local/httpd/
mkdir benet.com vim index.html
mkdir accp.com vim index.html
vim /usr/local/httpd/conf/httpd.conf 改两个地方:如下
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
service httpd restart
设置基于域名的虚拟主机
先增加host记录:
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
基于IP地址的就不演示了。需要添加一块网卡,要重启机器,格式如下:
IP地址虚拟主机设置:建立虚拟主机配置文件
1
2
3
4
5
6
7
8
# vim/etc/httpd/conf.d/virtual.conf
DocumentRoot "/usr/local/httpd/benet.com/"
DocumentRoot "/usr/local/httpd/accp.com/"
基于域名的虚拟主机加身份验证:
1
2
3
4
5
6
7
8
9
10
11
12
13
DocumentRoot "/usr/local/httpd/benet.com/"
ServerName www.benet.com
AllowOverride authconfig
AuthType Basic
AuthName "Restrict area"
AuthUserFile "/usr/local/httpd/conf/.awspad"
Require valid-user
创建认证文件
12
# cd /usr/local/httpd/
# bin/htpasswd -c /usr/local/httpd/conf/.awspad hujianli
4.源代码安装Mysql# useradd -M -u 49 -s /sbin/nologin mysql# tar zxf mysql-5.1.55.tar.gz -C /usr/src/# cd /usr/src/mysql-5.1.55/#./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312# make && make install
# cp support-files/my-medium.cnf /etc/my.cnf# cd /usr/local/mysql/bin/#./mysql_install_db --user mysql# chown -R root:mysql /usr/local/mysql/# chown -R mysql /usr/local/mysql/var/# ln -s /usr/local/mysql/bin/* /usr/local/bin/# ln -s /usr/local/mysql/lib/mysql/* /usr/lib/# ln -s /usr/local/mysql/include/mysql/* /usr/include/# cd /usr/src/mysql-5.1.55/# cp support-files/mysql.server /etc/rc.d/init.d/mysqld# chmod a+x /etc/rc.d/init.d/mysqld#chkconfig --add mysqld#chkconfig --list mysqldmysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭# service mysqld restartMySQL manager or server PID file couldnot be found! [失败]Starting MySQL.Manager of pid-file quitwithout updating fi[失败]问题:启动MYSQL报错StartingMySQL.Manager of pid-file quit without updating fi[失败]# rm -rf /var/lib/mysql# /usr/local/mysql/bin/mysql_install_db --user=mysql重启看看是否可用# service mysqld startStarting MySQL. [确定]# ps aux|grep mysql如果不可用请继续如下操作# kill -9 mysqld_safe(Pid number)# kill -9 mysqld (Pid number)重启看看是否可用# service mysqld start# cd ~好了mysql安装完毕。接下来准备php的安装环境:
5.源代码安装libmcrypt# tar zxf libmcrypt-2.5.7.tar.gz -C/usr/src/# cd /usr/src/libmcrypt-2.5.7/[root@crushlinuxlibmcrypt-2.5.8]# ./configure[root@crushlinuxlibmcrypt-2.5.8]# make && makeinstall[root@crushlinuxlibmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib/[root@crushlinuxlibmcrypt-2.5.8]# cd ~
6.源代码安装mhash# tar zxf mhash-0.9.9.9.tar.gz -C/usr/src/# cd /usr/src/mhash-0.9.9.9/[root@crushlinuxmhash-0.9.9.9]# ./configure[root@crushlinuxmhash-0.9.9.9]# make && makeinstall[root@crushlinuxmhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib/[root@crushlinuxmhash-0.9.9.9]# cd ~
7.源代码安装mcrypt# tar zxf mcrypt-2.6.8.tar.gz -C/usr/src/# cd /usr/src/mcrypt-2.6.8/[root@crushlinuxmcrypt-2.6.8]# ./configure[root@crushlinuxmcrypt-2.6.8]# make && makeinstall[root@crushlinuxmcrypt-2.6.8]# cd ~这个问题没解决。。。。我会尽快找到答案的,,未完待续。。
页:
[1]