下载地址

http://httpd.apache.org/download.cgi
http://apr.apache.org/download.cgi
http://mirrors.sohu.com/mysql/
http://www.php.net/downloads.php
https://www.phpmyadmin.net/
http://www.awstats.org/#DOWNLOAD

------------安装Apache----下面两个插件是httpd2.4以后的版本所需要-----

tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.28.tar.gz
mv apr-1.6.2 httpd-2.4.28/srclib/apr
mv apr-util-1.6.0 httpd-2.4.28/srclib/apr-util

安装插件

yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl

切换目录

cd httpd-2.4.28

定制
./configure \ //定制
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

编译并安装

make && make install //编译并安装

启动文件

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd //
vi /etc/init.d/httpd //放在service管理工具里
linux lamp

添加service管理器

chkconfig --add httpd //将httpd加入到service管理器

优化启动

vi /usr/local/httpd/conf/httpd.conf
ServerName

软件连接配置以及命令

ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/

关闭防火墙 / 或者配置防火墙规则

systemctl stop firewalld.service
setenforce 0

启动服务

service httpd start
netstat -anpt | grep 80

---------------以下安装mysql------------------------
安装mysql插件

yum -y install \
ncurses \
ncurses-devel \
bison \
cmake

创建MySQL用户

useradd -s /sbin/nologin mysql

解压

tar xf mysql-boost-5.7.20.tar.gz //解压MySQL
cd mysql-5.7.20/ //进入MySQL

编译

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost -DWITH_SYSTEMD=1

注:如果报错一下错误

CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
This CMake script will look for boost in . If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:455 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/root/mysqlsoftware/mysql-5.7.17/CMakeFiles/CMakeOutput.log".
See also "/root/mysqlsoftware/mysql-5.7.17/CMakeFiles/CMakeError.log".

解决方法如下:

1.在/usr/local下创建一个名为boost的文件夹
mkdir -p /usr/local/boost
2.进入这个新创建的文件夹然后下载boost
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
3.解压
tar -xvzf boost_1_59_0.tar.gz
4.继续cmake,添加上红色部分
rm -rf CMakeCache.txt
在编译的时候加上-DWITH_BOOST=/usr/local/boost
注:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ mysql安装的根目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ 设置mysql.sock路径,必须是绝对路径,默认是/tmp/mysql.sock
-DSYSCONFDIR=/etc \ mysql配置文件所在目录
-DSYSTEMD_PID_DIR=/usr/local/mysql \ //pid文件路径
-DDEFAULT_CHARSET=utf8 \ 设置mysql的默认字符集为utf-8
-DDEFAULT_COLLATION=utf8_general_ci \ 设置默认字符集校对规则
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ //以下为优化参数,存储引擎选项,静态编译一个存储引擎到服务器,1为开启,添加INNOBASE引擎支持不加建表时报错
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 添加ARCHIVE引擎支持,不加建表时报错
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 添加BLACKHOLE引擎支持 ,不加建表时报错
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ 添加PERFSCHEMA引擎支持,不加建表时报错
-DMYSQL_DATADIR=/usr/local/mysql/data \ mysql数据库文件存放目录
-DWITH_BOOST=boost \ 指向boost库所在目录
-DWITH_SYSTEMD=1
可以使用systemd控制mysql服务

-DWITH_PARTITION_STORAGE_ENGINE=1 安装支持数据库分区

编译安装

方式一:
make && make install
方式二:
make -j4(真机几核的双倍)
make install

修改文件用户

chown -R mysql:mysql /usr/local/mysql/

修改mysql配置文件

vi /etc/my.cnf MySQL默认主配置文件
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock 设置sock文件位置

[mysql]
port = 3306
default-character-set=utf8 设置mysql客户端默认字符集
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql 设置mysql的安装目录
datadir = /usr/local/mysql/data 设置mysql数据库的数据的存放目录
port = 3306 设置3306端口
character_set_server=utf8 创建新表时将使用的默认存储引擎
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

修改文件权限

chown mysql:mysql /etc/my.cnf

设置环境变量

echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile 方便Linux系统识别
echo 'export PATH' >> /etc/profile

生效

source /etc/profile

mysql初始化
cd /usr/local/mysql/ 在安装目录中进行初始化

bin/mysqld \ 初始化数据库
--initialize-insecure \
--user=mysql \ 用户
--basedir=/usr/local/mysql \ 基础目录
--datadir=/usr/local/mysql/data 工作目录

添加system管理器

cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/ 添加到system管理器

重加载

systemctl daemon-reload 加载
systemctl start mysqld
netstat -anpt | grep 3306

开机自启

systemctl enable mysqld

初始化root用户

mysqladmin -u root -p password "abc123" //给root账号设置密码为abc123 ,提示输入的是初始密码时,直接回车

登入数据库

mysql -u root -p 设置有密码的情况下,要加-p

-----------------以下安装PHP-----------

安装php插件

yum -y install \ PHP配置插件
libjpeg \ f
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel

----------------以下两行可能用不到,如果报错有perl的,使用以下两行

vi /usr/local/httpd/bin/apxs
#!/usr/bin/perl -w ----

解压并定制

tar xjvf php-7.1.10.tar.bz2
cd php-7.1.10
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql-sock=/usr/local/mysql/mysql.sock \ PHP的Unix socket通信文件
--with-mysqli \
--with-zlib \
--with-curl \ 允许curl扩展
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-mbstring \
--enable-xml \
--enable-session \ 允许php会话session
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip

编译并并安装

make && make install

添加配置文件

cp php.ini-development /usr/local/php/lib/php.ini
vi /usr/local/php/lib/php.ini

mysqli.default_socket = /usr/local/mysql/mysql.sock 指定sock文件位置
date.timezone = Asia/Shanghai 更改时区

验证php模块

/usr/local/php/bin/php -m //验证安装的模块

修改配置文件

vi /etc/httpd.conf //在合适位置新增,相近原则

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

DirectoryIndex index.php index.html

删除web网页文件

rm -f /usr/local/httpd/htdocs/index.html

添加web网页文件并验证php
vi /usr/local/httpd/htdocs/index.php

phpinfo();
?>

访问网页
http://ip地址/

测试数据库
--------下面测试数据库工作是否正常-----

mysql -u root -p

CREATE DATABASE myadm; 创建新的数据库mydam
GRANT all ON myadm. TO 'myadm'@'%' IDENTIFIED BY 'admin123'; 允许用户mydam在任何地方通过admin123登录
GRANT all ON myadm.
TO 'myadm'@'localhost' IDENTIFIED BY 'admin123'; 最大化权限
flush privileges;

测试数据库连接

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

$link=mysqli_connect('192.168.80.182','myadm','admin123');
if($link) echo "

Success!!

";
else echo "Fail!!";
?>

---以下安装phpMyadmin------
安装论坛

unzip phpMyAdmin-4.7.6-all-languages.zip -d /opt/
mv phpMyAdmin-4.7.6-all-languages /usr/local/httpd/htdocs/myadm

安装

cd /usr/local/httpd/htdocs/myadm
cp config.sample.inc.php config.inc.php

修改安装文件

vi config.inc.php

$cfg['Servers'][$i]['host'] = '127.0.0.1'; //把localhost 改成IP 31行

访问

http://IP地址/myadm

管理数据库:使用root以及前面为root配置的密码登录管理系统

mv htcos/* ./