LAMP搭建流程
1、环境准备
[root@localhost opt]# systemctl stop firewalld.service
[root@localhost opt]# setenforce 0
2、安装环境依赖包
[root@localhost opt]# yum install -y\
gcc \ #c语言编译器
gcc-c++ \ #c编译器
make \ #源代码编译器
pcre\ #pcre函数库
pcre-devel \ #pcre接口开发包
expat-devel \ #用于支持网站解析HTML、XML文件
perl #perl 语言编译器
[root@localhost opt]# yum -y install gcc gcc-c++ make pcre-devel expat-devel perl pcre
3、解压软件包
[root@localhost opt]# cd /opt/
[root@localhost lamp]# tar xf apr-1.6.2.tar.gz
[root@localhost lamp]# tar xf apr-util-1.6.0.tar.gz
[root@localhost lamp]# tar jvxf httpd-2.4.29.tar.bz2
4.移动apr包 apr-util包到安装目录中,并切换到 httpd-2.4.29目录中
[root@31yml opt]#mv apr-1.6.2 httpd-2.4.29/srclib/apr
[root@31yml opt]#mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
[root@31yml opt]#cd httpd-2.4.29/
[root@31yml httpd-2.4.29]#ls
ABOUT_APACHE buildconf httpd.dsp libhttpd.mak README.cmake
acinclude.m4 CHANGES httpd.mak LICENSE README.platforms
Apache-apr2.dsw CMakeLists.txt httpd.spec Makefile.in ROADMAP
Apache.dsw config.layout include Makefile.win server
apache_probes.d configure INSTALL modules srclib
ap.d configure.in InstallBin.dsp NOTICE support
build docs LAYOUT NWGNUmakefile test
BuildAll.dsp emacs-style libhttpd.dep os VERSIONING
BuildBin.dsp httpd.dep libhttpd.dsp README
5.编译安装
[root@31yml httpd-2.4.29]#./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
[root@31yml httpd-2.4.29]# make
[root@31yml httpd-2.4.29]# make install
6方便操作建立软连接
[root@localhost httpd-2.4.29]#cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
将文件拷入/etc/init.d/httpd
[root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/
建立配置文件软连接放入etc目录下
[root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/bin/* /usr/local/bin/
将启动文件放入/usr/local/bin/目录下可以直接使用
7添加httpd系统服务
方法1
[root@localhost httpd-2.4.29]# vi /etc/init.d/httpd ###开头加入
# chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
# description: Apache is a World Wide Web server
[root@localhost httpd-2.4.29]# chkconfig --add httpd ##将httpd加入service管理器
[root@localhost httpd-2.4.29]# vi /usr/local/httpd/conf/httpd.conf #修改主机地址
51 Listen 192.168.91.100:80 ##将你的地址加入
52 #Listen ##52注释掉
199 ServerName www.kgc.com ##写入域名
[root@localhost conf]# vim /etc/hosts ##添加域名
#行末加入
192.168.91.100 www.kgc.com
[root@localhost httpd-2.4.29]# service httpd start
#启动服务注意使用了service启动不要使用systemctl关闭,两种无法混用
[root@31yml httpd-2.4.29]#netstat -natp|grep 80
tcp 0 0 192.168.177.100:80 0.0.0.0:* LISTEN 84415/httpd
在真机中 打开网页测试
编译安装mysql
1.安装依赖包、创建用户mysql
[root@localhost ~]# yum install -y ncurses-devel autoconf cmake
yum -y install \
ncurses \ #字符终端下图形互动功能的动态库
ncurses-devel \ #ncurses开发包
bison \ #语法分析器
cmake #mysql需要用到的cmake编译安装包
useradd -s /sbin/nologin mysql
2.解压软件包并切换到编译目录,并编译安装
###上传mysql-boost-5.7.20.tar.gz到opt目录下###
cd /opt
tar xf mysql-boost-5.7.20.tar.gz
cd /opt/mysql-5.7.20/
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
#回车
######编译安装####
[root@31yml mysql-5.7.20]#make -j2 && make install
#####数据库目录进行权限调整###
[root@31yml mysql-5.7.20]#chown -R mysql:mysql /usr/local/mysql/
#####建立调整配置文件########
[root@31yml mysql-5.7.20]#vim /etc/my.cnf##gg到文首,dG删除全文
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 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
[root@31yml mysql-5.7.20]#chown mysql:mysql /etc/my.cnf
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
source /etc/profile
cd /usr/local/mysql/
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
netstat -anpt | grep 3306
mysqladmin -u root -p password "abc123" //刚开始没密码是空的直接回车,然后输入密码abc123,在此确认abc123,这是在root账户下运行的
mysql -u root -p ##这个命令敲下,提示要输入密码,这个就是刚才设置的密码abc123
编译安装php
编译安装PHP 解析环境
1、将安装PHP 所需软件包传到/opt目录下
2、安装GD库和GD库关联程序,用来处理和生成图片
yum -y install \
gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
3、配置软件模块
[root@31yml mysql]#cd /opt/
[root@31yml opt]#tar xf php-7.1.10.tar.bz2
cd /opt/php-7.1.10/
4、编译及安装
make -j2 && make install
5、复制模版文件作为PHP 的主配置文件,并进行修改
[root@31yml php-7.1.10]#cp /opt/php-7.1.10/php.ini-development /usr/local/php7/php.ini
6、优化把PHP 的可执行程序文件放入路径环境变量的目录中便于系统识别
ln -s /usr/local/php7/bin/* /usr/local/bin/
php -m 查看PHP 加载了哪些模块
7、修改httpd 服务的配置文件,让apache支持PHP
vim /etc/httpd.conf
AddType application/x-httpd-php .php --393行--插入以下内容(插在下面,原行不删)
AddType application/x-httpd-php-source .phps ##这里的点前面空格一定要加,否则报错
DirectoryIndex index.html index.php --255行--修改首页文件名设置
LoadModule php7_module modules/libphp7.so ---156行 ---检查支持php7的模块是否存在(可以用'/'在文件中查找 )
8、验证PHP 测试页
rm -rf /usr/local/httpd/htdocs/index.html
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>
[root@31yml htdocs]#service httpd restart
[root@31yml htdocs]#mysql -u root -p
mysql> CREATE DATABASE bbs; //创建一个数据库//
mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; //把bbs数据库里面所有表的权限授予给bbsuser,并设置密码//
mysql>flush privileges; //刷新数据库//
[root@31yml opt]#cd /opt/
[root@localhost opt]# unzip /opt/Discuz_X2.5_SC_UTF8.zip -d /opt/dis
[root@31yml opt]#cd dir_SC_UTF8/
[root@31yml dir_SC_UTF8]#ls
readme upload utility
[root@31yml dir_SC_UTF8]#cp -r upload/ /usr/local/httpd/htdocs/bbs
[root@31yml dir_SC_UTF8]#cd /usr/local/httpd/htdocs/bbs/
[root@31yml bbs]#chown -R daemon ./config
[root@31yml bbs]#chown -R daemon ./data
[root@31yml bbs]#chown -R daemon ./uc_client
[root@31yml bbs]#chown -R daemon ./uc_server/data
标签:httpd,31yml,local,流程,LAMP,usr,mysql,root,搭建 From: https://www.cnblogs.com/bacolate/p/17649410.html