- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章ubuntu 20.04上搭建LNMP环境的方法步骤由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
简单说明 。
由于之前是用Centos7搭建的,后来使用ubuntu 20.04的系统做为个人开发环境,所以想在ubuntu上也搭建一下环境,和Centos有一些小区别所以记录一下仅供学习.
安装前准备 。
下载软件: php:7.3.18 nginx:1.18.0 mariadb:10.5.4 。
解压文件:
1
2
3
|
tar
zxf php-7.3.18.
tar
.gz
tar
zxf mariadb-10.5.4.
tar
.gz
tar
zxf nginx-1.18.0.
tar
.gz
|
安装Nginx 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
sudo
groupadd -r nginx &&
sudo
useradd
-r -g nginx -s
/sbin/nologin
-d
/usr/local/nginx
nginx
sudo
apt
install
-y libpcre3-dev zlib1g-dev
cd
/home/allen/
下载
/nginx-1
.18.0
.
/configure
--user=nginx --group=nginx
make
-j 4 &&
sudo
make
install
sudo
/usr/local/nginx/sbin/nginx
-t
#nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
#nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
sudo
mv
/usr/local/nginx/conf/nginx
.conf
/usr/local/nginx/conf/nginx
.conf.back
sudo
vim
/usr/local/nginx/conf/nginx
.conf
user nginx;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application
/octet-stream
;
sendfile on;
keepalive_timeout 65;
log_format main
'$remote_addr || $remote_user || $time_local || $request || $status || $body_bytes_sent || $http_referer || $http_user_agent || $http_x_forwarded_for'
;
include
/data/www/
*/*.conf;
}
sudo
chown
-R nginx:nginx
/usr/local/nginx
sudo
vim
/lib/systemd/system/nginx
.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=
/usr/local/nginx/sbin/nginx
ExecReload=
/usr/local/nginx/sbin/nginx
-s reload
ExecStop=
/usr/local/nginx/sbin/nginx
-s quit
PrivateTmp=
true
[Install]
WantedBy=multi-user.target
sudo
systemctl
enable
nginx
#Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
reboot
|
重启后看看有没有启动成功 。
安装Mariadb 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
sudo
rm
-rf
/etc/mysql
sudo
apt remove -y mysql-common
sudo
apt autoremove -y
sudo
apt
install
-y cmake libncurses5-dev libgnutls28-dev
sudo
groupadd -r mysql &&
sudo
useradd
-r -g mysql -s
/sbin/nologin
-d
/usr/local/mariadb
mysql
sudo
mkdir
-p
/data/db
/var/log/mariadb
cd
/home/allen/
下载
/mariadb-10
.5.4/
cmake . -DCMAKE_INSTALL_PREFIX=
/usr/local/mariadb
-DMYSQL_DATADIR=
/data/db
-DSYSCONFDIR=
/etc
-DWITHOUT_TOKUDB=1 -DMYSQL_UNIX_ADDR=
/tmp/mysql
.sock -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci
make
-j 4 &&
sudo
make
install
sudo
/usr/local/mariadb/scripts/mysql_install_db
--user=mysql --datadir=
/data/db
sudo
vim
/etc/my
.cnf
[mysqld]
datadir =
/data/db
socket =
/tmp/mysql
.sock
# 建议禁用符号链接,防止各类安全风险
symbolic-links = 0
collation-server = utf8mb4_general_ci
init-connect =
'SET NAMES utf8mb4'
character-
set
-server = utf8mb4
[mysql]
default-character-
set
= utf8mb4
[client]
port = 3306
socket =
/tmp/mysql
.sock
default-character-
set
= utf8mb4
[mysqld_safe]
log-error =
/var/log/mariadb/mariadb
.log
pid-
file
=
/var/run/mariadb/mariadb
.pid
sudo
cp
/usr/local/mariadb/support-files/mysql
.server
/etc/init
.d
/mariadb
sudo
vim
/etc/profile
.d
/mariadb
.sh
export
PATH=$PATH:
/usr/local/mariadb/bin/
sudo
chmod
0777
/etc/profile
.d
/mariadb
.sh
source
/etc/profile
.d
/mariadb
.sh
sudo
/etc/init
.d
/mariadb
start
#Starting mariadb (via systemctl): mariadb.service.
sudo
/usr/local/mariadb/bin/mysql_secure_installation
#NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
# SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
#In order to log into MariaDB to secure it, we'll need the current
#password for the root user. If you've just installed MariaDB, and
#haven't set the root password yet, you should just press enter here.
#Enter current password for root (enter for none):
#OK, successfully used password, moving on...
#Setting the root password or using the unix_socket ensures that nobody
#can log into the MariaDB root user without the proper authorisation.
#You already have your root account protected, so you can safely answer 'n'.
#Switch to unix_socket authentication [Y/n] y
#Enabled successfully!
#Reloading privilege tables..
# ... Success!
#You already have your root account protected, so you can safely answer 'n'.
#Change the root password? [Y/n] y
#New password:
#Re-enter new password:
#Password updated successfully!
#Reloading privilege tables..
# ... Success!
#By default, a MariaDB installation has an anonymous user, allowing anyone
#to log into MariaDB without having to have a user account created for
#them. This is intended only for testing, and to make the installation
#go a bit smoother. You should remove them before moving into a
#production environment.
#Remove anonymous users? [Y/n] y
# ... Success!
#Normally, root should only be allowed to connect from 'localhost'. This
#ensures that someone cannot guess at the root password from the network.
#Disallow root login remotely? [Y/n] n
# ... skipping.
#By default, MariaDB comes with a database named 'test' that anyone can
#access. This is also intended only for testing, and should be removed
#before moving into a production environment.
#Remove test database and access to it? [Y/n] y
# - Dropping test database...
# ... Success!
# - Removing privileges on test database...
# ... Success!
#Reloading the privilege tables will ensure that all changes made so far
#will take effect immediately.
#Reload privilege tables now? [Y/n] y
# ... Success!
#Cleaning up...
#All done! If you've completed all of the above steps, your MariaDB
#installation should now be secure.
#Thanks for using MariaDB!
sudo
systemctl
enable
mariadb
sudo
chown
mysql:mysql -R
/usr/local/mariadb
/data/db
/var/log/mariadb
reboot
|
重启后看看有没有启动成功 。
安装PHP 。
1
2
3
4
5
6
7
8
|
sudo
apt
install
-y libxml2-dev libssl-dev libbz2-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev pkg-config libxslt1-dev libzip-dev libfreetype6-dev libfontconfig1-dev autoconf
sudo
groupadd -r php &&
sudo
useradd
-r -g php -s
/sbin/nologin
-d
/usr/local/php
php
sudo
vim
/etc/sudoers
php ALL=(ALL:ALL) ALL
cd
/home/allen/
下载
/php-7
.3.18/
.
/configure
--prefix=
/usr/local/php
\--
exec
-prefix=
/usr/local/php
--with-fpm-user=php --with-fpm-group=php --
enable
-zip --with-curl --with-gettext --with-iconv-
dir
--with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --
enable
-bcmath --
enable
-inline-optimization --
enable
-mbregex --
enable
-mbstring --
enable
-opcache --
enable
-pcntl --
enable
-shmop --
enable
-soap --
enable
-sockets --
enable
-sysvsem --
enable
-sysvshm --
enable
-xml --
enable
-fpm --with-freetype-
dir
--with-gd --with-libxml-
dir
--with-pcre-regex --
enable
-libxml --
enable
-zip --with-png-
dir
--with-jpeg-
dir
|
有一个错误:
configure: error: freetype-config not found. 。
解决办法: 据说:https://www.doopsky.com/ops/981.html 。
这是由于在 Ubuntu 19.04 中 apt-get 安装的 libfreetype6-dev 版本为 2.9.1-3 http://changelogs.ubuntu.com/changelogs/pool/main/f/freetype/freetype_2.9.1-3/changelog 在 changelog 中写到:
The `freetype-config' script is no longer installed by default (Closes: #871470, #886461). All packages depending on libfreetype6-dev should use pkg-config to find the relevant CFLAGS and libraries. freetype-config 被替代成 pkg-config ,新版本使用 pkg-config 管理 CFLAGS 和 库.
所以解决方法如下: 主要的思路就是用pkg-config代替freetype-config。安装pkg-config,我在上面已经安装了 。
1
2
3
4
5
6
7
8
9
|
cat ./configure | grep "freetype-config" -n
34847: if test -f "$i/bin/freetype-config"; then
34849: FREETYPE2_CONFIG="$i/bin/freetype-config"
34855: as_fn_error $? "freetype-config not found." "$LINENO" 5
36568: if test -f "$i/bin/freetype-config"; then
36570: FREETYPE2_CONFIG="$i/bin/freetype-config"
36576: as_fn_error $? "freetype-config not found." "$LINENO" 5
sed -i "s/freetype-config/pkg-config/g" ./configure
|
1
2
3
4
5
|
cat ./configure | grep "FREETYPE2_CONFIG --cflags" -n
34858: FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
36579: FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
sed -i "s/FREETYPE2_CONFIG --cflags/FREETYPE2_CONFIG freetype2 --cflags/g" ./configure
|
1
2
3
4
5
|
cat ./configure | grep "FREETYPE2_CONFIG --libs" -n
34859: FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
36580: FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
sed -i "s/FREETYPE2_CONFIG --libs/FREETYPE2_CONFIG freetype2 --libs/g" ./configure
|
1
2
3
4
5
6
|
cat ./ext/gd/config.m4 | grep "freetype-config" -n
188: if test -f "$i/bin/freetype-config"; then
190: FREETYPE2_CONFIG="$i/bin/freetype-config"
196: AC_MSG_ERROR([freetype-config not found.])
sed -i "s/freetype-config/pkg-config/g" ./ext/gd/config.m4
|
重新编译安装就OK 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Thank you
for
using PHP.
make
-j 4 &&
sudo
make
install
sudo
cp
php.ini-production
/usr/local/php/lib/php
.ini
sudo
cp
/usr/local/php/etc/php-fpm
.conf.default
/usr/local/php/etc/php-fpm
.conf
sudo
cp
/usr/local/php/etc/php-fpm
.d
/www
.conf.default
/usr/local/php/etc/php-fpm
.d
/www
.conf
vim
/usr/local/php/etc/php-fpm
.d
/www
.conf
listen.mode = 0666
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000
slowlog = log/$pool.log.slow
rlimit_files = 1024
sudo
vim
/etc/profile
.d
/php
.sh
export
PATH=$PATH:
/usr/local/php/bin/
sudo
chmod
0777
/etc/profile
.d
/php
.sh &&
source
/etc/profile
.d
/php
.sh
sudo
cp
sapi
/fpm/php-fpm
.service
/etc/systemd/system/php
.service
|
安装xdebug 。
下载xdebug http://pecl.php.net/get/xdebug-2.9.6.tgz 。
1
2
3
4
5
6
|
cd
/home/allen/
下载
tar
zxf xdebug-2.9.6.tgz
cd
xdebug-2.9.6
phpize
.
/configure
--with-php-config=
/usr/local/php/bin/php-config
make
-j 4 &&
sudo
make
install
|
安装Apcu 。
下载Apcu http://pecl.php.net/get/apcu-5.1.18.tgz 。
1
2
3
4
5
6
|
cd
/home/allen/
下载
tar
zxf apcu-5.1.18.tgz
cd
apcu-5.1.18
phpize
.
/configure
--with-php-config=
/usr/local/php/bin/php-config
make
-j 4 &&
sudo
make
install
|
编辑PHP.INI 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
sudo
vim
/usr/local/php/lib/php
.ini
date
.timezone = Asia
/Shanghai
expose_php = off
max_execution_time = 0
memory_limit = 4096M
display_errors = On
cgi.fix_pathinfo=0
extension_dir =
"/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/"
extension=pgsql
extension=apcu
zend_extension=
/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/xdebug
.so
[xdebug]
xdebug.var_display_max_children=10240
xdebug.var_display_max_data=20480
xdebug.var_display_max_depth=50
|
启动 。
1
2
3
4
5
6
|
sudo
systemctl
enable
php-fpm
sudo
chown
-R mysql:mysql
/usr/local/mariadb
sudo
chown
-R nginx:nginx
/usr/local/nginx
sudo
chown
-R php:php
/usr/local/php
reboot
|
到此这篇关于ubuntu 20.04上搭建LNMP环境的方法步骤的文章就介绍到这了,更多相关ubuntu 20.04搭建LNMP内容请搜索我以前的文章或继续浏览下面的相关文章希望大家以后多多支持我! 。
原文链接:https://blog.csdn.net/xjcallen/article/details/106987381 。
最后此篇关于ubuntu 20.04上搭建LNMP环境的方法步骤的文章就讲到这里了,如果你想了解更多关于ubuntu 20.04上搭建LNMP环境的方法步骤的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!