最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ubuntu 20.04上搭建LNMP環(huán)境的方法步驟

 更新時(shí)間:2020年07月30日 10:24:32   作者:好好開車  
這篇文章主要介紹了ubuntu 20.04上搭建LNMP環(huán)境的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

簡(jiǎn)單說明

由于之前是用Centos7搭建的,后來使用ubuntu 20.04的系統(tǒng)做為個(gè)人開發(fā)環(huán)境,所以想在ubuntu上也搭建一下環(huán)境,和Centos有一些小區(qū)別所以記錄一下僅供學(xué)習(xí)。

安裝前準(zhǔn)備

下載軟件:
php:7.3.18
nginx:1.18.0
mariadb:10.5.4

解壓文件:

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

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

重啟后看看有沒有啟動(dòng)成功

安裝Mariadb

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
# 建議禁用符號(hào)鏈接,防止各類安全風(fēng)險(xiǎn)
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

重啟后看看有沒有啟動(dòng)成功

安裝PHP

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

有一個(gè)錯(cuò)誤:

configure: error: freetype-config not found.

解決辦法:
據(jù)說: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,我在上面已經(jīng)安裝了

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
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
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
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

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

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

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

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

啟動(dòng)

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 

到此這篇關(guān)于ubuntu 20.04上搭建LNMP環(huán)境的方法步驟的文章就介紹到這了,更多相關(guān)ubuntu 20.04搭建LNMP內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • CentOS7 重新分配分區(qū)大小的實(shí)現(xiàn)方法

    CentOS7 重新分配分區(qū)大小的實(shí)現(xiàn)方法

    這篇文章主要介紹了CentOS7 重新分配分區(qū)大小的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Ubuntu14.04安裝、配置與卸載QT5的步驟詳解

    Ubuntu14.04安裝、配置與卸載QT5的步驟詳解

    這篇文章主要介紹了Ubuntu14.04安裝、配置與卸載QT5詳細(xì)步驟,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Linux基礎(chǔ)之正則表達(dá)式,用戶、組管理命令介紹

    Linux基礎(chǔ)之正則表達(dá)式,用戶、組管理命令介紹

    正則表達(dá)式簡(jiǎn)單來說就是一種行字符串處理的方式,通過一些特殊符號(hào)的輔助,可達(dá)到搜索、刪除、替換等某些特定字符串的處理方式
    2016-10-10
  • Linux云服務(wù)器安裝JDK和Tomcat的詳細(xì)步驟(推薦)

    Linux云服務(wù)器安裝JDK和Tomcat的詳細(xì)步驟(推薦)

    這篇文章主要介紹了Linux云服務(wù)器安裝JDK和Tomcat的詳細(xì)步驟,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • centos7系統(tǒng)部署k8s集群詳細(xì)介紹

    centos7系統(tǒng)部署k8s集群詳細(xì)介紹

    大家好,本篇文章主要講的是centos7系統(tǒng)部署k8s集群詳細(xì)介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • linux下實(shí)時(shí)查看tomcat運(yùn)行日志的方法

    linux下實(shí)時(shí)查看tomcat運(yùn)行日志的方法

    下面小編就為大家?guī)硪黄猯inux下實(shí)時(shí)查看tomcat運(yùn)行日志的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起 小編過來看看吧
    2016-11-11
  • ubuntu18.04 安裝qt5.12.8及環(huán)境配置的詳細(xì)教程

    ubuntu18.04 安裝qt5.12.8及環(huán)境配置的詳細(xì)教程

    這篇文章主要介紹了ubuntu18.04 安裝qt5.12.8及環(huán)境配置的教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-05-05
  • linux NFS 服務(wù)安全加固方法

    linux NFS 服務(wù)安全加固方法

    NFS(Network File System)是 FreeBSD 支持的一種文件系統(tǒng),它允許網(wǎng)絡(luò)中的計(jì)算機(jī)之間通過 TCP/IP 網(wǎng)絡(luò)共享資源。不正確的配置和使用 NFS,會(huì)帶來安全問題,需要的朋友可以參考下
    2018-02-02
  • Linux高并發(fā)踩過的坑及性能優(yōu)化介紹

    Linux高并發(fā)踩過的坑及性能優(yōu)化介紹

    大家好,本篇文章主要講的是Linux高并發(fā)踩過的坑及性能優(yōu)化介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • Linux 6下安裝編譯安裝Nginx的步驟

    Linux 6下安裝編譯安裝Nginx的步驟

    這篇文章主要介紹了Linux 6下安裝編譯安裝Nginx的步驟的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下
    2017-10-10

最新評(píng)論

汝阳县| 肥城市| 阜阳市| 财经| 庆元县| 澄江县| 兴安盟| 宜川县| 河池市| 抚远县| 营山县| 桐柏县| 江北区| 潼关县| 临猗县| 德化县| 察隅县| 探索| 博湖县| 习水县| 绥阳县| 台州市| 长武县| 临夏市| 岳普湖县| 上栗县| 栾城县| 五家渠市| 通山县| 治县。| 巴青县| 文登市| 肃宁县| 华宁县| 青龙| 大姚县| 友谊县| 类乌齐县| 稷山县| 铜梁县| 阳谷县|