文档章节

lamp 搭建

西红柿长
 西红柿长
发布于 2014/05/23 16:48
字数 1393
阅读 20
收藏 0

-前期准备工作———————————————–

关闭防火墙以及selinux

#service iptables stop

#chkconfig iptables off

#vi /etc/selinux/config                                  #把SELINUX=enforcing 修改为disabled

保存并退出。重新启动电脑


yum -y install gcc gcc-c++ autoconf nss_ldap libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers pcre pcre-devel make wget vim cmake gd gd-devel libevent libevent-devel zip unzip


1.安装apr

tar -zxf apr-util-1.5.3.tar.gz
cd apr-1.5.1
./configure --prefix=/usr/local/apr
[root@1010 apr-1.5.1]# make && make install

2.安装apr-util
tar xf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
[root@1010 apr-util-1.5.3]#  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@1010 apr-util-1.5.3]# make && make install

3.以上两步编译完成,现正式开始编译httpd-2.4.9
[root@1010 ~]# tar -zxf httpd-2.4.9.tar.gz
[root@1010 ~]# cd httpd-2.4.9
[root@1010 httpd-2.4.9]#

./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
--prefix=/usr/local/apache 安装路径

--sysconfdir=/etc/httpd 配置文件路径

--enable-so 允许运行时加载DSO模块

--enable-ssl 如果不加载将无法使用使用https

--enable-cgi 允许使用cgi脚本

--enable-rewrite 支持URL重写机制

--with-zlib 支持网络通用压缩库

--with-pcre 支持pcre

--with-apr=/usr/local/apr 指定apr的安装路径

--with-apr-util=/usr/local/apr-util/ 指定apr-util的安装路径

--enable-modules=most 启用大多数常用的模块

--enable-mpms-shared=all 启用MPM所有支持的模式

--with-mpm=event 默认使用enevt模式


[root@1010 httpd-2.4.9]# make
[root@1010 httpd-2.4.9]# make install

自启动脚本:
#!/bin/bash

# Startup script for the Apache2.0.X Web Server
# Fixed by Comsenz - Nanu (nanu@discuz.com)

# chkconfig: - 85 15

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

INITLOG_ARGS=""

apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
RETVAL=0

start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}

case "$1" in
start)
start
 ;;
stop)
stop
 ;;
status)
status $httpd
RETVAL=$?
 ;;
restart)
stop
start
 ;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
 ;;
reload)
reload
 ;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
 ;;
*)
echo $"Usage: $prog

{start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtes                                       t}"
exit 1
esac

exit $RETVAL


修改/etc/httpd/httpd.conf
Servername
[root@1010 httpd-2.4.9]# chkconfig --add httpd
[root@1010 httpd-2.4.9]# chkconfig httpd on
[root@1010 httpd-2.4.9]# chkconfig --list httpd
httpd           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

#---------------------------------------------------------------------------------------------------------------------------------------

#--------------------------------------------------------------------------------------------------------------------------------------- 

 

[root@1010 ~]# groupadd mysql
[root@1010 ~]# useradd -g mysql mysql -s /sbin/nologin
[root@1010 ~]# tar -zxf mysql-5.6.12.tar.gz
[root@1010 ~]# cd mysql-5.6.12
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

make && make install
启动MySQL

添加服务,拷贝服务脚本到init.d目录,并设置开机启动

cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start  --启动MySQL
配置用户

MySQL启动成功后,root默认没有密码,我们需要设置root密码。

设置之前,我们需要先设置PATH,要不不能直接调用mysql

修改/etc/profile文件,在文件末尾添加

PATH=/usr/local/mysql/bin:$PATH
export PATH
关闭文件,运行下面的命令,让配置立即生效

source /etc/profile
现在,我们可以在终端内直接输入mysql进入,mysql的环境了

执行下面的命令修改root密码

mysql -uroot 
mysql> SET PASSWORD = PASSWORD('123456');
若要设置root用户可以远程访问,执行

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '123456' WITH GRANT OPTION;

delete from mysql.user where user='';  ← 删除匿名用户
flush privileges;
select user,host,password from mysql.user;

 

#---------------------------------------------------------------------------------------------------------------------------------------

#--------------------------------------------------------------------------------------------------------------------------------------- 

useradd -s /sbin/nologin -M fpmuser
[root@1018 ~]# tar -zxf php-5.5.12.tar.gz
[root@1018 ~]# cd php-5.5.12
./configure --prefix=/usr/local/php  \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-freetype-dir --with-jpeg-dir \
--with-png-dir --enable-zip \
--with-zlib --enable-xml  \
--with-gd  --with-mhash  \
--with-libxml-dir=/usr  --enable-mbstring  \
--enable-fpm --with-fpm-user=fpmuser \
--with-fpm-group=fpmuser --disable-ipv6 \
--enable-sockets --with-openssl \
--with-bz2 --with-curl --enable-dba=shared \
--with-pcre-dir --with-gd --with-jpeg-dir --with-png-dir \
--with-zlib-dir --enable-mbstring \
--with-mysql=/usr/local/mysql/ \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-bcmath  --with-gettext
make
make install

[root@1018 etc]# cp -a php-fpm.conf.default php-fpm.conf
[root@1018 etc]# cd ..
[root@1018 php]# sbin/php-fpm

[root@1018 php]# lsof -i :9000
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 10219    root    7u  IPv4 222366      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 10220 fpmuser    0u  IPv4 222366      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 10221 fpmuser    0u  IPv4 222366      0t0  TCP localhost:cslistener (LISTEN)

LoadModule php5_module        modules/libphp5.so
此模块调用php

配置apache
找到DirectoryIndex index.html index.html.var
修改为DirectoryIndex index.html index.php
接着增加如下内容:
AddType application/x-httpd-php .php
修改完如下:
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
AddType application/x-httpd-php .php

[root@1018 htdocs]# pwd
/usr/local/apache/htdocs
[root@1018 htdocs]# ls
index.bak  index.php
[root@1018 htdocs]# cat index.php
<?php
phpinfo();
?>
[root@1018 htdocs]#

打开测试机访问即可  192.168.100.18

 

tar -zxf nginx-1.6.0.tar.gz
cd  nginx-1.6.0

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_stub_status_module --with-pcre

make && make install

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
# Source function library.
. /etc/rc.d/init.d/functions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
# Source networking configuration.
. /etc/sysconfig/network
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
lockfile=/var/lock/subsys/nginx
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
make_dirs() {
   # make required directories
   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
   for opt in $options; do
       if [ `echo $opt | grep '.*-temp-path'` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
restart() {
    configtest &> /dev/null|| return $?
    stop
    sleep 1
    start
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
force_reload() {
    restart
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
rh_status() {
    status $prog
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
rh_status_q() {
    rh_status >/dev/null 2>&1
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

/etc/init.d/nginx start

192.168.100.18

 

 

© 著作权归作者所有

共有 人打赏支持
上一篇: 个人vimrc配置
下一篇: ssh 密钥
西红柿长
粉丝 0
博文 8
码字总数 2828
作品 0
东城
系统管理员
私信 提问
使用docker虚拟化技术,lamp架构,搭建wordpress博客服务

使用docker虚拟化技术,lamp架构,搭建wordpress博客服务 使用平台 Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-91-generic x86_64) 搭建思路步骤 需求:使用wprdpress搭建一个私人博客,并且将服务...

fsx2550553488
05/28
0
0
Dockerfile快速搭建自己专属的LAMP环境

自从用上公司的Docker环境,再也很少直接在系统上搭建LAMP环境了,在摸索如何用Docker搭建LAMP环境,折腾多种方式后,觉得Dockerfile是一种不错的方式。 当然一开始自己用Dockerfile肯定无从...

小和
2016/11/02
35
0
Apache配置https证书并跳转

对于网站实现https安全访问,需要做到以下几步: 1、在域名解析商处申请ssl证书,该证书可以免费申请,申请下来后包括很多web配置的证书类型 如下图: 2、搭建web服务,我这里搭建的环境是L...

Bill_Xing
08/01
0
0
阿里云ubuntu14.04下lamp环境搭建の备忘

以下内容大部分来自于网络上的收集,百度搜lamp能搜到很多文字教程。百度lamp搭建 推荐几个视频教程: 在Ubuntu Server下搭建LAMP环境 PHP环境LAMP/LNMP安装与配置 我收藏在印象笔记里的备忘...

卖萌哥、
2017/11/08
0
0
Ubuntu16.04编译安装Zabbix3.4监控系统

准备工作 因为zabbix的前端是PHP的代码,因此运行zabbix需要搭建LAMP或者LNMP环境,这里我们选用LAMP环境。 整个系统中,zabbix采用编译安装,便于定位文件位置以及后续版本的升级,其余环境...

影夜Linux
10/07
0
0

没有更多内容

加载失败,请刷新页面

加载更多

区块链安全 - 以太坊短地址攻击

1 基础知识 EVM虚拟机在解析合约的字节码时,依赖的是ABI的定义,从而去识别各个字段位于字节码的什么地方。关于ABI,可以阅读这个文档: https://github.com/ethereum/wiki/wiki/Ethereum-C...

HiBlock
8分钟前
0
0
自定义函数及内部函数

变量的作用域 局部变量 global $Global及其他超全局数组 静态变量 仅初始化赋值 保留于内存直到response才销毁 global和static变量的区别 global:局部变量全局话 static:定义静态局部变量 函...

关元
9分钟前
0
0

中国龙-扬科
21分钟前
1
0
python包

https://www.lfd.uci.edu/~gohlke/pythonlibs/

陆朋
32分钟前
1
0
一文弄懂“分布式锁”,一直以来你的选择依据正确吗?

本文主要会关注的问题是“分布式锁”的问题。 多线程情况下对共享资源的操作需要加锁,避免数据被写乱,在分布式系统中,这个问题也是存在的,此时就需要一个分布式锁服务。 常见的分布式锁实...

Java干货分享
39分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部