编译安装lamp

2 篇文章 0 订阅
1 篇文章 0 订阅

#编译安装lamp

前几天买了阿里云上centos的服务器, 就在上面搭建了lamp. 是用ssh 连过去的,一点都没有图形页面, aliyun 提供的yum仓库里的版本不是很高, 所以整个过程都是编译安装的, 也受益匪浅, 特写此博客.

安装apache

apache相关文件

pcre-8.37.tar.gz [http://nchc.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz]
apr-util-1.5.4.tar.gz [http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz]
apr-1.5.2.tar.gz [http://apache.fayea.com//apr/apr-1.5.2.tar.gz]
httpd-2.4.17.tar.gz [http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.17.tar.gz]

$ tar -zxvf “包名” -C /usr/local/src

安装apr

$  cd /usr/local/src/apr-1.5.2
$  ./configure --prefix=/usr/local/apr  
$  make
$  make install

安装apr-util

$  cd ../apr-util-1.5.4
$  ./configure --prefix=/usr/local/apr-util \
 --with-apr=/usr/local/apr/bin/apr-1-config
$  make
$  make install

安装pcre

$  cd ../pcre-8.37/
$  ./configure --prefix=/usr/local/pcre \
 --with-apr=/usr/local/apr/bin/apr-1-config
$  make
$  make install

安装httpd

$  cd ../httpd-2.4.17/
$ ./configure  --prefix=/usr/local/apache2 \
 --with-apr=/usr/local/apr/bin/apr-1-config \
 --with-apr-util=/usr/local/apr-util/bin/apu-1-config  \
 --with-pcre=/usr/local/pcre/bin/pcre-config \
 --enable-dav  \
 --enable-so
$  make
$  make install

加入service

$  cp /usr/local/apache/bin2/apachectl /etc/rc.d/init.d/httpd

$  vim /etc/rc.d/init.d/httpd

在文件头加入

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description:http server
chkconfig --add httpd
chkconfig --level 345 httpd on

配置apache

$  vim /usr/local/apache2/config/httpd.conf
  • 修改ServerName
 ServerName localhost:80
  • 修改为可访问
<Directory />
AllowOverride all
Require all granted
</Directory>
  • 修改 documentroot
DocumentRoot "/var/www"
<Directory "/var/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

安装mysql5.7

卸载旧版本

rpm
  • 安装 : rpm -ivh
  • 卸载 : rpm -e –nodeps
  • 检查 : rpm -qa
卸载
$  rpm -e --nodeps mysql-5.1.73-5.el6_6.i686
$  rpm -e --nodeps mysql-server-5.1.73-5.el6_6.i686
$  rpm -e --nodeps mysql-lib-5.1.73-5.el6_6.i686
$  rm -fr /usr/lib/mysql   
$  rm -fr /usr/include/mysql
$  rm -f my.cnf 
$  rm -fr /var/lib/mysql

安装

$  groupadd mysql
$  useradd -r -g mysql -s /bin/false mysql
$  cd /usr/local
$  tar -zxvf /path/to/mysql-VERSION-OS.tar.gz    # -C 指定路径
$  ln -s full-path-to-mysql-VERSION-OS mysql    #ln -s "源文件" "链接文件"
$  cd mysql
$  mkdir mysql-files
$  chmod 770 mysql-files
$  chown -R mysql .
$  chgrp -R mysql .
$  bin/mysql_install_db --user=mysql    # Before MySQL 5.7.6
$  bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up 此时会提示root的密码(最后一行) 一定要记住.
$  bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up
$  chown -R root .
$  chown -R mysql data mysql-files

修改配置(不然进不去)

$  cp support-files/my-default.cnf /etc/my.cnf             #移动默认配置到/etc 并命名为my.cnf

Next command is optional

$  cp support-files/mysql.server /etc/init.d/mysql.server   # 添加到 service

$  vim /etc/profile                # 设置到环境变量

在最后加上

    MYSQL_HOME=/usr/local/mysql/bin
    export PATH=$PATH:$MYSQL_HOME
    source /etc/profile                 # 使环境生效

    chkconfig --add mysql.server         #开机自启
    chkconfig -list             #看开服务状态
    chkconfig --level 345 mysql on       #如果3,4,5没有开 手动设置

启动

$  service mysql.server start           # 启动 sql-server

安装php 5.6.15

解压 进入
$  ./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/local/libxml2 \
--with-zlib-dir \
--with-curl --with-bz2  \
--with-gd \
--enable-gd-native-ttf \
--with-png-dir=/usr/lib \
--with-jpeg-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--with-gettext --with-openssl \
--with-fpm-user=www --with-fpm-group=www \
--with-gmp \
--with-mhash \
--enable-calendar \
--enable-ftp \
--enable-zip \
--enable-pdo \
--enable-bcmath \
--enable-shmop \
--enable-mbstring \
--enable-sockets  \
--enable-fpm \
--enable-inline-optimization \
--enable-sigchild \
--enable-sysvsem \
--enable-sysvshm
如果出现 not find xml-config
$  yun install libxml

$  yun install libxml-devel -y

$  find / -name "xml-config"         #找到就好
如果出现 not find libmysqlclient_r.so
$  find / -name "libmysqlclient*"    #找到 libmysqlclient

$  ln -s libmysqlclient.so.20.0.9 libmysqlclient_r.so

$  make
$  make test                     #测试  (我的结果见 附录 phptest 结果)
$  make install
配置文件
$  cp php.ini-development /usr/local/php/lib/php.ini

配置apache的php支持

$  vim /usr/local/apache2/config/httpd.conf
;LoadModule php5_module        
;modules/libphp5.so
###去掉 ;
LoadModule php5_module        
modules/libphp5.so

<IfModule mime_module>下加入

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值