Ubuntu 22.04.2 LTS编译安装PHP-7.2.34与Nginx1.22.0

环境介绍

Ubuntu版本:22.04.2 LTS
Nginx版本:1.22.0
PHP版本:7.2.34

所需文件

在这里插入图片描述

安装步骤

解压

tar -zxf openssl-1.1.1l.tar.gz
tar -zxf php-7.2.34.tar.gz
tar -zxf nginx-1.22.0.tar.gz

安装编译所需环境

apt -y install gcc make g++ libtool-bin libexpat1-dev build-essential
apt install libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev -y
apt install libxml2-dev libcurl4-openssl-dev -y
apt install pkg-config -y
apt install pkgconf -y

编译安装Nginx

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module && make && make install

编译安装openssl

./config --prefix=/usr/local/openssl && make && make install

编译安装php

./configure --prefix=/usr/local/php --enable-fpm --with-curl --with-openssl=/usr/local/openssl --with-mysqli --with-pdo-mysql && make && make install

复制php.ini-production到/usr/local/php/etc/php.ini

cp php.ini-production /usr/local/php/etc/php.ini

配置nginx与php

将nginx与php加入到systemctl

php

vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

nginx

vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重新加载systemd配置文件

systemctl daemon-reload

取消注释location段并添加index.php

vim /usr/local/nginx/conf/nginx.conf

在这里插入图片描述
在这里插入图片描述

修改php-fpm.conf.default为php-fpm.conf

mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

修改www.conf.default为www.conf

mv /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

修改fastcgi_params

vim /usr/local/nginx/conf/fastcgi_params
#末尾添加如下内容
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

创建nobody用户组

groupadd nobody

开启nginx和php-fpm服务

systemctl start php-fpm.service
systemctl start nginx.service
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Ubuntu 22.04.2 LTS安装MariaDB,可以按照以下步骤进行操作: 1. 打开终端,并使用以下命令安装MariaDB的软件包: ``` sudo apt install mariadb-server ``` 2. 安装完成后,可以使用以下命令启动MariaDB服务: ``` sudo systemctl start mariadb ``` 3. 若要设置MariaDB在系统启动时自动启动,可以运行以下命令: ``` sudo systemctl enable mariadb ``` 4. 在安装完成后,可以运行以下命令来对MariaDB进行一些初始设置: ``` sudo mysql_secure_installation ``` 这个命令将引导你完成一些安全设置,例如设置root密码、移除匿名用户、禁止root远程登录等。 5. 如果需要远程连接到MariaDB服务器,你可以修改MariaDB的配置文件。通过以下命令来编辑配置文件: ``` sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf ``` 6. 保存并关闭文件后,重新启动MariaDB服务以使更改生效: ``` sudo systemctl restart mariadb ``` 现在,你已经在Ubuntu 22.04.2 LTS上成功安装并进行了一些基本配置的MariaDB数据库服务器。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Ubuntu22.04安装MariaDB](https://blog.csdn.net/tang_t/article/details/131471622)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [ubuntu22.04安装zabbix6.0 LTS](https://blog.csdn.net/qq_15514497/article/details/129317169)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想看一次满天星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值