LAMP

linux+apache+mysql+php LAMPl
linux+nginx+mysql+php LNMP
mysql
准备工作
1.将现有系统rpm的mariadb 和 mariadb-server卸载
2.删除配置文件
# rm -rf /etc/my.cnf

安装mysql

# useradd -M -s /sbin/nologin mysql
# tar xf mysql-5.6.22.tar.gz -C /usr/src/
# cd /usr/src/mysql-5.6.22/
安装mysql需要的依赖包
# yum install gcc gcc-c++ cmake make bison ncurses ncurses-devel openssl-devel perl-Data-Dumper -y
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.22 -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql-5.6.22/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1

-DCMAKE_INSTALL_PREFIX 指定安装位置
-DSYSCONFDIR 指定配置文件目录位置
-DMYSQL_DATADIR 指定数据库文件目录位置
-DINSTALL_MANDIR 指定帮助手册存放目录
-DMYSQL_TCP_PORT 指定port
-DMYSQL_UNIX_ADDR 指定套接字文件
-DDEFAULT_CHARSET 指定默认字符集
-DEXTRA_CHARSETS 附属字符集
-DDEFAULT_COLLATION 设置mysql的默认字符校对
-DWITH_SSL 支持ssl
-DWITH_EMBEDDED_SERVER 构建嵌入式mysql库
-DENABLED_LOCAL_INFILE 支持从本地导入数据
-DWITH_INNOBASE_STORAGE_ENGINE 支持innodb引擎

# make -jgrep 'processor' /proc/cpuinfo |wc -l&& make install

MySQL初始化===========

# ln -s /usr/local/mysql-5.6.22/ /usr/local/mysql

1. 初始化

# cd /usr/local/mysql
# chown -R mysql.mysql .
# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
# ls data
ibdata1 ib_logfile1 performance_schema
ib_logfile0 mysql test

2. 生成MySQL主配置文件

使用源码包提供的默认配置文件,生产环境自定义配置文件
# cp support-files/my-default.cnf /etc/my.cnf

3. 生成MySQL Sys V脚本

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld

4.启动服务设置开机启动

# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
# chkconfig mysqld on

5. 配置MySQL环境变量

# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
# . /etc/profile

测试mysql

mysql 进入交互式操作


apr 安装

# tar -xf apr-1.5.2.tar.gz -C /usr/src
# cd /usr/src/apr-1.5.2
# ./configure --prefix=/usr/local/apr
# make && make install

apr-util安装

[root@os1 apr-util-1.5.4]#tar xf apr-util-1.5.4.tar.gz -C /usr/src
[root@os1 apr-util-1.5.4]#cd /urs/src/apr-util-1.5.4
[root@os1 apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@os1 apr-util-1.5.4]# make && make install

apache 安装 如果有问题可能是pcre-devel软件包没有安装

# yum install libxml2-devel bzip2-devel -y
# tar xf httpd-2.4.23.tar.gz -C /usr/src/
# cd /usr/src/httpd-2.4.23/
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-modules=all --enable-mods-shared=all --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre --with-libxml2 --with-mpm=event --enable-mpms-shared=all
# make && make install

配置apache环境变量

[root@os1 httpd-2.4.23]# vim /etc/profile.d/httpd.sh
export PATH=$PATH:/usr/local/apache/bin
[root@os1 httpd-2.4.23]#. /etc/profile.d/httpd.sh

启动服务

[root@os1 httpd-2.4.23]# httpd -k start
[root@os1 httpd-2.4.23]# ps -ef |grep httpd
root 406 1 0 16:15 ? 00:00:00 httpd -k start
daemon 407 406 0 16:15 ? 00:00:00 httpd -k start
daemon 408 406 0 16:15 ? 00:00:00 httpd -k start
daemon 409 406 0 16:15 ? 00:00:00 httpd -k start
root 492 1843 0 16:15 pts/0 00:00:00 grep httpd
开机启动写到/etc/rc.local 给这个文件添加执行权限

PHP安装

# tar xf php-5.5.30.tar.gz -C /usr/src/
# cd /usr/src/php-5.5.30/

安装php所需依赖包

# yum install libxml2-devel bzip2-devel -y
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d/ --with-libxml-dir --with-openssl --with-pcre-regex --with-zlib --with-bz2 --with-libxml-dir --with-pcre-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --enable-zip --enable-maintainer-zts

注:若mysql由yum安装,则需把--with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config替换成--with-mysql=mysqlnd --with-mysqli=mysqlnd

#make && make install
# cp php.ini-production /etc/php.ini
# grep php5 /etc/httpd/httpd.conf
LoadModule php5_module modules/libphp.so

安装完会生成 /usr/local/apache/modules/libphp5.so apache支持php的网页

# vim /etc/httpd/httpd.conf //添加蓝色字体
271 
272 DirectoryIndex index.php index.html
273 AddHandler php5-script .php
274 AddType text/html .php
275 

重启httpd服务

#httpd -k stop
#httpd -k start

测试php和apache的连接


# cd /usr/local/apache/htdocs
# rm -rf index.html
# vim index.php

使用浏览器访问apache服务可以看到php的帮助信息表示成功

创建mysql的用户和密码

# /usr/local/mysql/bin/mysqladmin -u root password 123456 帐号密码
# /usr/local/mysql/bin/mysql -u root -p123456 登录测试mysql是否能使用

测试mysql和和php的连接

# vim index.php

使用浏览器访问apache服务可以看到Success字符串信息表示成功

安装农场

1.解压软件 解压的软件包叫upload

# unzip farm-ucenter1.5.zip
2.# rm -rf /usr/local/apache/htdocs/*
3.# cp -r upload/* /usr/local/apache/htdocs/
4.# chmod 777 /usr/local/apache/htdocs/* -R
数据库
5.登录mysql数据库创建discuz库
# /usr/local/mysql/bin/mysql -u root -p123456 登录
mysql>create database discuz ; 创建数据库
6.导入农场数据
# /usr/local/mysql/bin/mysql -u root -p123456 -D discuz < /usr/local/apache/htdocs/qqfarm.sql

浏览器:
http://192.168.0.171
根据提示更改

# vim /etc/php.ini
short_open_tag = On
将Off更改为On
数据库服务器:localhost
数据库名 discuz
数据库用户名: root
数据库密码: 123456

你可能感兴趣的:(LAMP)