阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

LAMP安装各种问题解决方案

148次阅读
没有评论

共计 7246 个字符,预计需要花费 19 分钟才能阅读完成。

LAMP 环境配置安装注意安装步骤及说明事项。 

LAMP 安装各种问题解决

1. 访问 ftp 报错

LAMP 安装各种问题解决方案

解决:

关闭 selinux

vi /etc/selinux/config

内容修改为:selinux=disable

之后重启 reboot。

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

LAMP 安装各种问题解决方案

LAMP 安装各种问题解决方案

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

# 测试 apache

浏览器打开: http:// 虚拟机 IP

看到 “it works!”, 即为成功

配置虚拟主机

1)配置 host 文件

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

增加域名记录

如:

192.168.9.38    www.ec1.com

192.168.9.38    www.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

增加虚拟主机记录

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com

    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

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host2.example.com

        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

</VirtualHost>

<VirtualHost *:80>

        DocumentRoot “/var/www/shop

    ServerName www.ec1.com

</VirtualHost>

注意:/var/www/shop 以上三个目录 var www shop 的其他用户必须有 x 可执行权限

LAMP 安装各种问题解决方案

LAMP 安装各种问题解决方案

LAMP 安装各种问题解决方案

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># mkdir -p /usr/local/gd

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

  1. 在 httpd.conf(Apache 主配置文件)中增加:

AddType application/x-httpd-php .php   

  1. 找到下面这段话:

<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

在 index.html 前面添加 index.php

  1. 建立 php 测试网页

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

输入如下内容:

<?php

phpinfo();

?>

  1. 重启 apache

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

  1. 再次浏览器查看 http:// 虚拟机 IP

如果看到 php 信息, 工作就完成了!

  1. 安装 MySQL

    1. 安装 cmake

    shell># cd /home/jinnan/tar

    shell># tar zxvf cmake-2.8.5.tar.gz

    shell># cd cmake-2.8.5

    shell># ./bootstrap

    shell># make && make install

    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

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

    3. 配置并初始化 MySQL

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

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

    (数据库用户信息不小心删除光了,删除 data 目录,从此开始执行以下指令 , 直至结束)

    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;

  2. 配置开机自启动服务项

    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 启动失败

    [root@localhost 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 端口使用情况

    [root@localhost 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

    LAMP 安装各种问题解决方案

    查看 80 的使用者是谁端口

    [root@localhost httpd-2.2.19]# ps 28195

    PID TTY STAT TIME COMMAND

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

    LAMP 安装各种问题解决方案

    经过分析知道了 80 端口被系统的一个进程占用,这个进程是旧的 apache 服务

    将这个进程杀之

    [root@localhost httpd-2.2.19]# kill -9 28195

    [root@localhost httpd-2.2.19]#

    LAMP 安装各种问题解决方案

    十一.卸载操作系统自带 apache

    LAMP 安装各种问题解决方案

    1. 删除默认 apache 进程
  • ps –A | grep http
  • 杀死 apache 对应进程

LAMP 安装各种问题解决方案

killall httpd 杀死全部的 httpd 进程

  1. 把默认 apache 服务给删除

    LAMP 安装各种问题解决方案

  2. 启动自己的 apache

    LAMP 安装各种问题解决方案 

下面关于 LAMP 相关 的内容你可能也喜欢

LAMP 平台安装 Xcache 和 Memcached 加速网站运行  http://www.linuxidc.com/Linux/2015-06/118835.htm 

CentOS 7 下搭建 LAMP 平台环境  http://www.linuxidc.com/Linux/2015-06/118818.htm

CentOS 6.5 系统安装配置 LAMP(Apache+PHP5+MySQL)服务器环境 http://www.linuxidc.com/Linux/2014-12/111030.htm

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境  http://www.linuxidc.com/Linux/2014-10/107924.htm

Ubuntu 14.10 下安装 LAMP 服务图文详解  http://www.linuxidc.com/Linux/2014-12/110082.htm

LAMP 结合 NFS 构建小型博客站点  http://www.linuxidc.com/Linux/2015-08/121029.htm

CentOS7 下安装部署 LAMP 环境  http://www.linuxidc.com/Linux/2016-04/130653.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-10/136253.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计7246字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中