胸怀万里世界, 放眼无限未来。这篇文章主要讲述lnmp服务相关的知识,希望能为你提供帮助。
配置:
虚拟机恢复初始化
配置VM1网卡
配置永久IP地址(关闭防火、关闭安全linux)
使用远程连接软件
挂载好磁盘到mnt目录
配置好yum仓库
文章图片
文章图片
修改虚拟机内存和处理器
文章图片
文章图片
点Upload
文章图片
文章图片
进入远程连接软件 进入到/目录 查看软件包
文章图片
配置yum仓库
文章图片
安装Apache
解压缩
tar xf
apr-1.6.2.tar.gz
tar xf
apr-util-1.6.0.tar.gz
tar -xjf
httpd-2.4.29.tar.bz2
mv apr-1.6.2
httpd-2.4.29/srclib/apr
mv apr-util-1.6.0
httpd-2.4.29/srclib/apr-util
文章图片
安装服务
yum -y install \\
gcc \\
gcc-c++ \\
make \\
pcre-devel \\
expat-devel \\
perl \\
zlib-devel \\
zlib
进入目录
cd /httpd-2.4.29
安装服务
./configure \\
--prefix=/usr/local/httpd
\\
--enable-so \\
--enable-rewrite \\
--enable-charset-lite
\\
--enable-cgi
编译安装
make -j 8 & &
make install
文章图片
复制
cp
/usr/local/httpd/bin/apachectl /etc/init.d/httpd
编辑服务
vi /etc/init.d/httpd
将命令添加到文件的第二行第三行
#
chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
# description:
Apache is a World Wide Web server
文章图片
chkconfig
--add httpd
chkconfig
--list
文章图片
编辑文件 将ServerName前面#号删除
vi
/usr/local/httpd/conf/httpd.conf
文章图片
优化操作
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
安装服务
cd /
yum -y
install \\
ncurses \\
ncurses-devel \\
bison \\
cmake
文章图片
ncurses \\ > ncurses-devel > bison cmakca httpd-2.4.29j# ca / / I-it yum -y install \\ " style="visibility: visible; width: 449px; " data-type="inline">
添加用户
useradd
-s /sbin/nologin mysql
解压缩
tar xzvf
mysql-boost-5.7.20.tar.gz
切换目录
cd
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
文章图片
INSTALL PREFIX=/usr/10ca1/mysq1 \\ > -WYSQL UUIX AmR=/usr/10ca1/mysq1/mysq1.sock \\ > -DSYSCONFDIR=/etc \\ > -DSYSTEMD PID DIR=/usr/10ca1/mysq1 \\ > -DDEFAULT CHARSET=utf8 > -DDEFAULT \\ > -th1TH IMK)BASE STORAGE ENGINE-I \\ > -thiTH ARCHIVE STORAGE EWINE=I \\ > -th1TH BLACKPOLE STORAGE ENGINE-I \\ > STORAGE ENGINE-I \\ > DATADIR=/usr/loca1/mysq1/data \\ > BOOST=boost \\ > -rü1TH " style="visibility: visible; width: 570px; " data-type="inline">
编译安装
make -j 8
& & make install
文章图片
报错解决方法 将这个命令在敲几遍make -j
8 & & make install
文章图片
for instructions. : [sql/cmakeFiles/sql.dir/item_geofunc.cc.o] €?iR 4 make[2] make[2 : please submit a full bug report, with preprocessed source if appropriate. seefor instructions. make[2]: [sQl/CMakeFiles/sql.dir/item_geofunc buffer .cc.o] 4 " style="visibility: visible; width: 570px; " data-type="inline">
【lnmp服务】修改权限
chown -R
mysql.mysql /usr/local/mysql/
编辑配置文件
vi /etc/my.cnf 将里面内容全部删除
插入
[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
修改权限
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
daemon-reload
systemctl start
mysqld
netstat -anpt | grep
3306
systemctl enable
mysqld
mysqladmin -u root -p password "abc123" 默认回车
mysql -u root -p ctrl+d 退出 密码
abc123
安装服务
yum -y install \\
libjpeg \\
libjpeg-devel \\
libpng libpng-devel
\\
freetype
freetype-devel \\
libxml2 \\
libxml2-devel \\
zlib zlib-devel \\
curl curl-devel \\
openssl
openssl-devel
编辑配置文件
vi
/usr/local/httpd/bin/apxs
文章图片
#!/usr/bin/perl
-w
切换目录 解压缩 安装
cd /
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
\\
--with-mysqli \\
--with-zlib \\
--with-curl \\
--with-gd \\
--with-jpeg-dir \\
--with-png-dir \\
--with-freetype-dir
\\
--with-openssl \\
--enable-mbstring \\
--enable-xml \\
--enable-session \\
--enable-ftp \\
--enable-pdo \\
--enable-tokenizer \\
--enable-zip
编译安装
make -j 8
& & 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
搜索
文章图片
搜索date.timezone
文章图片
date.timezone =
Asia/Shanghai
/usr/local/php/bin/php
-m //验证安装的模块
vi /etc/httpd.conf //在合适位置新增
添加到.tgz下面
搜索AddType
application
文章图片
AddType
application/x-httpd-php .php
AddType
application/x-httpd-php-source .phps
搜索DirectoryIndex
在html后面添加index.php
文章图片
Directoryindex index. html I < / Ifflodule> " style="visibility: visible; width: 570px; " data-type="inline">
DirectoryIndex
index.php index.html
rm -f
/usr/local/httpd/htdocs/index.html
编辑配置文件
vi
/usr/local/httpd/htdocs/index.php
< ?php
phpinfo();
?>
systemctl start
httpd
systemctl restart
httpd
--------下面测试数据库工作是否正常-----
mysql -u root -p 密码 abc123
CREATE DATABASE
myadm;
GRANT all ON myadm.*
TO myadm@% IDENTIFIED BY admin123;
GRANT all ON myadm.*
TO myadm@localhost IDENTIFIED BY admin123;
flush privileges;
文章图片
CREATE DATABASE myadm; Query OK, 1 rt.* affected (0.01 sec) mysql> GRANT all ON myadm.* TO myadm@X IDENTIFIED BY ?admini23 ; Query 0K, e rows affected, 1 warning (e.?e sec) mysql> GRANT all ON myadm.? TO myadm@localhost IDENTIFIED BY admini23,? Query 0K, e rows affected, 1 warning (e.?e sec) mysql> flush privileges; Query OK, e rows affected (?.?e sec) " style="visibility: visible; width: 570px; " data-type="inline">
退出
编辑配置文件
vi
/usr/local/httpd/htdocs/index.php
< ?php
$link=mysqli_connect(192.168.1.100,myadm,admin123);
if($link) echo
"< h1> Success!!< /h1> ";
else echo
"Fail!!";
?>
---以下安装phpMyadmin------
切换目录
Cd /
解压缩
unzip phpMyAdmin-4.7.6-all-languages.zip
解压完成
文章图片
cp -r phpMyAdmin-4.7.6-all-languages
/usr/local/httpd/htdocs/
cd
/usr/local/httpd/htdocs/
ll查看
文章图片
cd
phpMyAdmin-4.7.6-all-languages/
cp
config.sample.inc.php config.inc.php
编辑配置文件
vi config.inc.php
$cfg[Servers][$i][host] = 127.0.0.1; //把localhost 改成IP 31行
文章图片
cd /usr/local/httpd/htdocs/
ll查看
文章图片
mv
phpMyAdmin-4.7.6-all-languages/ myadm
重启服务
systemctl start httpd
systemctl restart httpd
用户名myadm
密码 admin123
文章图片
推荐阅读
- 如何在一票面试者中,脱颖而出
- 前端开发(解决异步回调必备技能——Async/Await和Promise)
- RxJS实现“搜索”功能,这就是“可读”~
- Elasticsearch掰开揉碎第13篇SpringData操作ES基础篇
- jQuery ajaxSetup()方法用法详细介绍
- Scala包对象介绍和用法简介
- jQuery使用语法简介
- TCS数字面试体验2019(通过CodeVita)
- PHP addslashes()函数用法详细示例