文档章节

lamp 搭建

西红柿长
 西红柿长
发布于 2014/05/23 16:48
字数 1393
阅读 20
收藏 0
点赞 0
评论 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

 

 

© 著作权归作者所有

共有 人打赏支持
西红柿长
粉丝 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
在httpd-2.2和http-2.4中分别搭建wordpress博客系统和Discuz!论坛系统

在httpd-2.2和http-2.4中分别搭建wordpress博客系统和Discuz!论坛系统 一、 在这里我使用的是centos6.7和centos7.2进行操作。在搭建之前,需要事先搭建LAMP环境。 所谓LAMP环境,指的是linux...

运维小弟qaq
2017/09/08
0
0
日志主机搭建总结

日志主机搭建总结 这几天一直在自学linux,正好前段时间公司日志服务器坏了,我感觉到练手的时机到了,于是我就开始在网上找资料,一点点的去试着做一个日志主机。从LAMP开始,到rsyslog的调...

gaofengqiang
2014/10/13
0
0
快速生成网站

实验条件: 已经搭建好LAMP 环境 (使用一键安装lamp) 关闭selinux 关闭防火墙 下载依赖包 gcc gcc-c++ make 具体步骤 : 下载 lnmp安装包 解压 ./install.sh lamp 安装完毕后登入:http://...

2532176285
2017/03/15
0
0
CentOS 7中的httpd-2.4和CentOS 6中的httpd-2.2搭建wordpress博客系统和Discuz!论坛系统

在搭建wordpress博客系统和Discuz!论坛系统之前,我们需要在Centos中准备好LAMP环境。 现在以Centos 6为例演示其过程。 LAMP环境=linux+apche+mysql+php 在安装好的Centos 6.7中使用yun安装a...

001100ll
2017/09/06
0
0
LAMP的实现及其简单应用

LAMP的实现及其简单应用 前言: LAMP即Linux+Apache+Mysql+PHP,一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,...

我想告诉你
2014/05/21
0
0
Ubuntu Server 10.04,如何快速安装FTP服务?

Ubuntu Server 10.04安装很简单,可以很快就安装完LAMP与postfix 如何才可以快速添加一个FTP,使LAMP更文件? 小弟的LINUX太差,请大虾们指教,另外,Postfix如何上手?想顺便搭建邮件服务器...

灰灰
2010/05/14
3.6K
4
LNMP平台部署及应用

LAMP平台应该是目前应用最为广泛的网站服务器架构,但随着Nginx在企业中的使用越来越多,LNMP(或LEMP)架构也受到越来越多Linux系统工程师的青睐,其中"E"来自于Nginx的发音[engine x] 构建...

杨书凡
01/13
0
0
CentOS 7上安装WordPress详细步骤

一、搭建Wordpress服务器环境需求: php 5.2.4 或者更高版本、MySQL 5.0 或者更高版本。 二、搭建Wordpress平台: 以下以Wordpress3.92版本为例进行说明,如果大家想安装最近版本的话,安装完...

linuxprobe16
2016/12/03
24
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

spring boot中swagger2使用

1.pom.xml中添加 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version>......

说回答
7分钟前
0
0
tomcat虚拟路径的几种配置方法

tomcat虚拟路径的几种配置方法 一般我们都是直接引用webapps下面的web项目,如果我们要部署一个在其它地方的WEB项目,这就要在TOMCAT中设置虚拟路径了,Tomcat的加载web顺序是先加载 $Tomcat_ho...

Helios51
19分钟前
1
0
Mac 安装jupyter notebook的过程

MAC台式机 python:mac下自带Python 2.7.10 1.先升级了pip安装工具:sudo python -m pip install --upgrade --force pip 2.安装setuptools 工具:sudo pip install setuptools==33.1.1 3.安装......

火力全開
25分钟前
0
0
导航守卫解释与例子

“导航”表示路由正在发生改变。 正如其名,vue-router 提供的导航守卫主要用来通过跳转或取消的方式守卫导航。有多种机会植入路由导航过程中:全局的, 单个路由独享的, 或者组件级的。 记住...

tianyawhl
25分钟前
0
0
Java日志框架-logback配置文件多环境日志配置(开发、测试、生产)(原始解决方法)

说明:这种方式应该算是最通用的,原理是通过判断标签实现。 <!-- if-then form --> <if condition="some conditional expression"> <then> ... </then> </if> ......

浮躁的码农
39分钟前
1
0
FTP传输时的两种登录方式和区别

登录方式 匿名登录 用户名为: anonymous。 密码为:任何合法 email 地址。 授权登录 用户名为:用户在远程系统中的用户帐号。 密码为:用户在远程系统中的用户密码。 区别 匿名登录 只能访问...

寰宇01
40分钟前
0
0
plsql developer 配置监听(不安装oracle客户端)

plsql developer 配置监听(不安装oracle客户端)

微小宝
47分钟前
1
0
数据库(分库分表)中间件对比

本人的宗旨就是,能copy的,绝对不手写。 分区:对业务透明,分区只不过把存放数据的文件分成了许多小块,例如mysql中的一张表对应三个文件.MYD,MYI,frm。 根据一定的规则把数据文件(MYD)和索...

奔跑吧代码
51分钟前
2
0
Netty与Reactor模式详解

在学习Reactor模式之前,我们需要对“I/O的四种模型”以及“什么是I/O多路复用”进行简单的介绍,因为Reactor是一个使用了同步非阻塞的I/O多路复用机制的模式。 I/O的四种模型 I/0 操作 主要...

hutaishi
58分钟前
1
0
【2018.07.16学习笔记】【linux高级知识 20.16-20.19】

20.16/20.17 shell中的函数 20.18 shell中的数组 20.19 告警系统需求分析

lgsxp
今天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部