LAMP安置教程

2022-11-16 15:28:11 作者:怎么样才能藏好孤独
导读:LAMP安装教程,LAMP环境配置安装注意安装步骤及说明事项。附件:1. 访问ftp报错解决:关闭selinuxvi /etc/selinux/config内容修改为: selinux=disabl...

LAMP情况设置装备摆设安置细致安置步调及阐明事变。

附件:

1. 访问ftp报错

办理:

封闭selinux

vi /etc/selinux/config

内容修改为: selinux=disable

之后重启reboot。

下图分别为selinux封闭前 和 封闭后:

2. 依靠软件盘问

http://rpmfind.net

一.安置gcc

gcc

cloog-ppl

ppl(libppl.so.7/libppl_c.so.2)

cpp

mpfr(libmpfr.so.1)

gcc-c++

libstdc++-devel

mpfr-2.4.1-6.el6.i686.rpm和ppl-0.10.2-11.el6.i686.rpm

快捷键rz sz:

rz、sz下令没找到?

安置lrzsz即可:

shell># yum -y install lrzsz

二.安置zlib压缩库

shell>## cd /home/jinnan/tar

shell># tar –zxvf zlib-1.2.5.tar.gz

shell># cd zlib-1.2.5

shell># ./configure //这个设置装备摆设编译下令不要加名目参数

shell># make && make install

三.安置apache

shell># cd /home/jinnan/tar

shell># tar -jxvf httpd-2.2.19.tar.bz2

shell># cd httpd-2.2.19

shell>#./configure --prefix=/usr/local/http2

--enable-modules=all

--enable-mods-shared=all

--enable-so

shell># make && make install

启动Apache

shell># /usr/local/http2/bin/apachectl start/stop/restart

#测试apache

扫瞄器打开: http://假造机IP

看到 "it works!",即为乐成

设置装备摆设假造主机

1)设置装备摆设host文件

打开C:/windows/system32/drivers/etc/hosts 文件

增添域名记载

如:

192.168.9.38www.ec1.com

192.168.9.38www.ec2.com

2) 增添假造主机

vi /usr/local/http2/conf/httpd.conf

取消# Include conf/extra/httpd-vhosts.conf

这一行前面的#号

储存退出

vi /usr/local/http2/conf/extra/httpd-vhosts.conf

增添假造主机记载

ServerAdmin [email protected]

DocumentRoot "/usr/local/http2/htdocs/ec1"

ServerName www.ec1.com

ServerAlias www.dummy-host.example.com

ErrorLog "logs/dummy-host.example.com-error_log"

CustomLog "logs/dummy-host.example.com-access_log" common

ServerAdmin [email protected]

DocumentRoot "/usr/local/http2/htdocs/ec2"

ServerName www.ec2.com

ErrorLog "logs/dummy-host2.example.com-error_log"

CustomLog "logs/dummy-host2.example.com-access_log" common

DocumentRoot "/var/www/shop"

ServerName www.ec1.com

细致:/var/www/shop 以上三个名目var www shop 的其他用户一定有x可实行权限

3)

shell># cd /usr/local/http2/htdocs

shell># mkdir ec1 ec2

shell># echo this is ec1.com > ec1/index.html

shell># echo this is ec2.com > ec2/index.html

4)重启apache

/usr/local/http2/bin/apachectl restart

5)扫瞄器打开www.ec1.com,和www.ec2.com

看到差别的网站内容,假造主机创建完毕!

安置图形库,为编译PHP做预备

libxml2-2.7.2.tar.gz

jpegsrc.v8b.tar.gz

libpng-1.4.3.tar.gz

freetype-2.4.1.tar.gz

gd-2.0.35.tar.gz

四.安置libxml2

shell># cd /home/jinnan/tar

shell># tar zxvf libxml2-2.7.2.tar.gz

shell># cd libxml2-2.7.2

shell>#./configure --prefix=/usr/local/libxml2

--without-zlib

shell># make && make install

五.安置jpeg8

shell># cd /home/jinnan/tar

shell># tar -zxvf jpegsrc.v8b.tar.gz

shell># cd jpeg-8b

shell>#./configure --prefix=/usr/local/jpeg

--enable-shared --enable-static

shell># make && make install

--enable-shared 把jpeg必要的函数库步伐都编译到该软件里边

长处:函数挪用速率快

缺点:软件自己比力大

--enable-static 静态方法(独立范例)函数处置惩罚,必要什么函数,顿时include来

长处:软件自己比力小

缺点:函数挪用速率慢

六.安置libpng

shell># cd /home/jinnan/tar

shell># tar zxvf libpng-1.4.3.tar.gz

shell># cd libpng-1.4.3

shell>#./configure #和zlib一样不要带参数,让它默认安置到相应名目

shell># make && make install

七.安置freetype(字体库)

shell># cd /home/jinnan/tar

shell># tar zxvf freetype-2.4.1.tar.gz

shell># cd freetype-2.4.1

shell>#./configure --prefix=/usr/local/freetype

shell># make && make install

八.安置GD库

shell># cd /home/jinnan/tar

shell># tar -zvxf gd-2.0.35.tar.gz

shell># cd gd-2.0.35

shell>#./configure --prefix=/usr/local/gd

--with-jpeg=/usr/local/jpeg/

--with-png --with-zlib

--with-freetype=/usr/local/freetype

shell># make && make install

九.安置 php5

shell># cd /home/jinnan/tar

shell># tar -jxvf php-5.3.6.tar.bz2

shell># cd php-5.3.6

shell>#./configure --prefix=/usr/local/php

--with-apxs2=/usr/local/http2/bin/apxs

--with-mysql=mysqlnd

--with-pdo-mysql=mysqlnd

--with-mysqli=mysqlnd

--with-freetype-dir=/usr/local/freetype

--with-gd=/usr/local/gd

--with-zlib --with-libxml-dir=/usr/local/libxml2

--with-jpeg-dir=/usr/local/jpeg

--with-png-dir

--enable-mbstring=all

--enable-mbregex

--enable-shared

shell># make && make install

复制php.ini设置装备摆设文件到指定名目

shell># cp php.ini-development /usr/local/php/lib/php.ini

设置装备摆设Apache使其支持php

vi /usr/local/http2/conf/httpd.conf

在httpd.conf(Apache主设置装备摆设文件)中增添:

AddType application/x-httpd-php .php

找到下面这段话:

DirectoryIndex index.html

在index.html 前面添加index.php

创建php测试网页

vi /usr/local/apache2/htdocs/index.php

输入如下内容:

<?php

phpinfo();

?>

重启apache

shell># /usr/local/http2/bin/apachectl restart

再次扫瞄器检察http://假造机IP

假如看到php信息,事情就完成了!

安置MySQL

1.安置cmake(更先辈的configure)

到光盘里边得到cmake并安置

rpm -ivh cmake*****

在光盘里边得到cmake并安置:

2.编译安置MySQL

shell># cd /home/jinnan/tar

shell># tar zxvf mysql-5.5.17.tar.gz

shell># cd mysql-5.5.17

shell># cmake

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/usr/local/mysql/data

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

(预备安置到那边

数据存储名目

默认的字符集

校对字符集)

(报错就安置ncurses-devel)

shell># mount .....挂载光盘/

shell># rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm

shell># rm -f CMakeCache.txt //删除该文件

shell># cmake 。。。 。。。 //重新cmake

shell># make && make install

给mysql复制一个设置装备摆设文件

shell># cp support-files/my-medium.cnf /etc/my.cnf

3.设置装备摆设并初始化MySQL

shell># useradd mysql(该mysql用户会存在于同名mysql的组下)

shell># chmod +x /usr/local/mysql

(数据库用户信息不警惕删除光了

① 删除/usr/local/mysql/data名目,

② 同时删除旧的mysql办事

> ps -A | grep mysql

> killall mysqld 或 kill -9 mysql历程号码

③ 从今开始实行以下指令,直至完结

)

shell># chown -R mysql.mysql /usr/local/mysql

初始化mysql数据库(创建体系默认数据库等)

shell># /usr/local/mysql/scripts/mysql_install_db

--user=mysql

--basedir=/usr/local/mysql

--datadir=/usr/local/mysql/data &

把mysql安置文件(除了data)的仆人都改为root,幸免数据库规复为出厂设置。

shell># chown -R root /usr/local/mysql

shell># chown -R mysql /usr/local/mysql/data

& 背景运行mysql办事

shell># /usr/local/mysql/bin/mysqld_safe --user=mysql &

//检察mysql是否有启动

shell># ps -A | grep mysql

测试数据库

shell># /usr/local/mysql/bin/mysql -u root

mysql> show databases;

接上步,修改mysql暗码(可不做此步,默认无暗码)

mysql> UPDATE user SET Password=password('123456') WHERE user='root';

mysql> flush privileges;

设置装备摆设开机自启动办事项

shell># cp 安置包解压名目/support-files/mysql.server /etc/init.d/mysqld

shell># chmod +x /etc/init.d/mysqld

shell># chkconfig --add mysqld

shell># chkconfig mysqld on //设置开机自启动

设置装备摆设文件路径:

shell># vi /etc/rc.d/rc.local

在 文件中增添启动相干办事的下令如下:

/usr/local/http2/bin/apachectl start

/usr/local/mysql/bin/mysqld_safe --user=mysql &

service vsftpd start

重新安置apache启动失败

[[email protected] httpd-2.2.19]# /usr/local/http2/bin/apachectl restart

httpd not running, trying to start

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

缘故原由是80端口被占用

办理:

检察80端口利用情形

[[email protected] httpd-2.2.19]# netstat -lnp|grep 80

tcp 0 0 :::80 :::* LISTEN 28195/httpd

unix 2 [ ACC ] STREAM LISTENING 6580 1957/gpm /dev/gpmctl

unix 2 [ ACC ] STREAM LISTENING 5422 1800/pcscd /var/run/pcscd.comm

检察80的利用者是谁端口

[[email protected] httpd-2.2.19]# ps 28195

PID TTY STAT TIME COMMAND

28195 ? Ss 0:00 /usr/local/http2/bin/httpd -k restart

颠末阐发知道了80端口被体系的一个历程占用,这个历程是旧的apache办事

将这个历程杀之

[[email protected] httpd-2.2.19]# kill -9 28195

[[email protected] httpd-2.2.19]#

十一.卸载操纵体系自带apache

制止默认的apache历程

> service httpd stop

2. 启动本身的apache

精彩图集