银河麒麟服务器操作系统V10 SP2 X86源码编译安装LNMP

本文详细介绍了如何在银河麒麟系统上搭建LNMP环境,包括安装Nginx、MySQL8.0.29和PHP7.4.16。首先关闭防火墙和Selinux,然后分别编译安装各组件,配置PHP环境,修改Nginx配置以支持PHP,最后测试服务是否正常启动。整个过程涉及多个依赖包的安装和配置文件的修改,确保了PHP的稳定运行。
摘要由CSDN通过智能技术生成

前言

LNMP是一个基于CentOS/Debian编写的Nginx、PHP、MySQL、PHPMyAdmin、eAccelerator一键安装包。可以在VPS、独立主机上轻松的安装LNMP生产环境。
LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。
Nginx较为稳定、功能丰富、安装配置简单、低系统资源
Nginx既可以在内部直接支持Rails和PHP,也可以支持作为HTTP代理服务器对外进行服务。Nginx用C编写,不论是系统资源开销还是CPU使用效率都比Perlbal好得多

目录

前言

1.安装nginx

2.安装Mysql8.0.29

3.安装PHP

3.1装依赖环境

3.2安装oniguruma-6.9.4

 3.3下载安装libmcrypt

 3.4编译安装php

4.修改配置

5.修改Nginx

6.检查服务是否启动

7.测试

总结



1.安装nginx

注意关闭防火墙以及Selinux,依赖环境的安装等。

#关闭防火墙,Selinux
  systemctl status firewalld.service 
  systemctl stop firewalld.service 
  systemctl disable firewalld.service 
# 关闭Selinux 重启生效
  sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
  reboot
#创建软件包存放目录
mkdir -p /opt/tools && cd /opt/tools
#创建不能登录的用户
useradd -M -s /sbin/nologin nginx
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
#配置
./configure \
--prefix=/usr/local/nginx \
--user=nginx --group=nginx \
--with-debug \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_slice_module \
--with-threads \
--with-http_addition_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module=dynamic \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_sub_module \
--with-http_xslt_module=dynamic \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream_realip_module \
--with-stream
#编译安装
make -j4 && make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
#制作service
cat >>/usr/lib/systemd/system/nginx.service<<EOF
[Unit]                                          
Description=nginx 
After=network.target 

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/bin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP \$MAINPID
ExecStop=/bin/kill -s TERM \$MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF
#刷新文件
systemctl daemon-reload
#nginx开机自启动
systemctl enable nginx.service

2.安装Mysql8.0.29

#下载Mysql源 
wget https://repo.mysql.com//mysql80-community-release-el8-4.noarch.rpm
#卸载系统中mariadb
rpm -e {mariadb-server,mariadb,mariadb-errmessage,mariadb-common}
#安装Mysql
[root@localhost mysqlpackage]# yum install mysql-community-server
#启动Mysql
[root@localhost ~]# systemctl start mysqld.service
#查看Mysql初始密码
#root@localhost:后面为默认初始密码
[root@localhost ~]# grep -r password /var/log/mysqld.log

2022-07-15T03:18:40.695138Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: MpkmgH0X+lPZ
#修改初始密码,注意密码要求8位数、大写字母、特殊字符
[root@localhost mysqlpackage]# mysql -uroot -pMpkmgH0X+lPZ
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.29 MySQL Community Server - GPL
 
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 #修改登录密码为Admin.123
mysql> ALTER USER USER() IDENTIFIED BY 'Admin.123';
设置Mysql开机自启

[root@localhost mysqlpackage]# systemctl enable mysqld.service

3.安装PHP

3.1装依赖环境

[root@localhost mysqlpackage]# yum -y install libtool sqlite-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel

3.2安装oniguruma-6.9.4

[root@localhost mysqlpackage]# wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
[root@localhost mysqlpackage]# tar -xvf  oniguruma-6.9.4.tar.gz
[root@localhost mysqlpackage]# cd oniguruma-6.9.4/
[root@localhost mysqlpackage]#./autogen.sh && ./configure --prefix=/usr --libdir=/lib64
[root@localhost mysqlpackage]# make && make install

 3.3下载安装libmcrypt

[root@localhost mysqlpackage]# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
[root@localhost mysqlpackage] tar xf libmcrypt-2.5.8.tar.gz
[root@localhost mysqlpackage] cd libmcrypt-2.5.8
[root@localhost mysqlpackage]# ./configure --prefix=/usr/local/libmcrypt
[root@localhost mysqlpackage]# make && make install

 3.4编译安装php

cd /opt/tools
[root@localhost tools]# tar -xvf php-7.4.16.tar.gz
[root@localhost tools]# cd php-7.4.16
#编辑PHP的配置项
./configure --prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx \
--enable-inline-optimization --disable-debug --disable-rpath \
--enable-shared --enable-soap  --with-xmlrpc \
--with-openssl --with-mhash  --with-sqlite3 \
--with-zlib --enable-bcmath --with-iconv --with-bz2 \
--enable-calendar --with-curl --with-cdb --enable-dom \
--enable-exif --enable-fileinfo --enable-filter \
--enable-ftp  --with-openssl-dir --with-zlib-dir \
--enable-gd-jis-conv --with-gettext --with-gmp --with-mhash \
--enable-json --enable-mbstring --enable-mbregex  \
--enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-zlib-dir --with-pdo-sqlite --with-readline --enable-session \
--enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg \
--enable-sysvsem --enable-sysvshm --with-xsl  \
--enable-mysqlnd-compression-support --with-pear \
--enable-opcache --disable-fileinfo
#编译安装
make -j 3 && make install 

4.修改配置

#添加环境变量
echo "export PATH=$PATH:/usr/local/php/bin" >> /etc/profile
source /etc/profile
#准备配置文件
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
ln -s /usr/local/php/etc/ /etc/php
#修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx
chown nginx.nginx /usr/local/php/etc/php-fpm.conf
chown -R nginx.nginx /etc/php
#禁用PHP功能
sed -i "s#disable_functions =#disable_functions =\"passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,wnam,posix_getpwuid, posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname\"#" /etc/php/php.ini 
#支持mysql
sed -i "s#pdo_mysql.default_socket=#pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
#" /etc/php/php.ini
sed -i "s#mysqli.default_socket =#mysqli.default_socket =/var/lib/mysql/mysql.sock
#" /etc/php/php.ini 

#设置开机自启,并启动
cp /opt/tools/php-7.4.16/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
chkconfig php-fpm on
systemctl start php-fpm

5.修改Nginx

#修改nginx
cp /usr/local/nginx/conf/nginx.conf{,.bak}
vim /usr/local/nginx/conf/nginx.conf
...
        location / {
            root   html;
            index  index.html index.htm index.php; #添加 index.php
        }
...
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #将/scripts$fastcgi_script_name修改为$document_root$fastcgi_script_name。
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
...
#检查配置
nginx -t 
systemctl start nginx   #启动nginx

6.检查服务是否启动

7.测试

#测试
cat > /usr/local/nginx/html/index.php <<eof
<?php
 phpinfo();
 ?>
eof
curl http://localhost/index.php 
#浏览器访问测试
http://127.0.0.1/index.php


总结

PHP7.4.16在银河麒麟SP2上已经完全兼容,但是依赖环境较为复杂,需要仔细。

为了在银河麒麟系统V10安装部署LNMP和zabbix6.4,你可以按照以下步骤进行操作: 1. 首先,安装LNMPLinuxNginx、MySQL、PHP)环境。你可以使用以下命令安装Nginx和MySQL: ``` yum install -y nginx mysql ``` 2. 安装PHP。你可以使用以下命令安装PHP及相关扩展: ``` yum install -y php php-fpm php-mysql ``` 3. 配置Nginx和PHP。根据你的需求,你需要编辑Nginx的配置文件(通常位于`/etc/nginx/nginx.conf`)和PHP的配置文件(通常位于`/etc/php.ini`)。确保Nginx正确指向你的网站目录,同时配置PHP的参数以满足zabbix的要求。 4. 下载并编译安装zabbix。你可以按照以下步骤进行操作: ``` # 下载zabbix源码包 wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/6.4.0/zabbix-6.4.0.tar.gz # 解压源码包 tar -xzvf zabbix-6.4.0.tar.gz # 进入解压后的目录 cd zabbix-6.4.0 # 编译安装zabbix ./configure --prefix=/usr/local/zabbix make install ``` 5. 创建zabbix用户。你可以使用以下命令创建一个具有合适权限的zabbix用户: [3] ``` useradd -u 8005 -M -s /sbin/nologin zabbix ``` 6. 配置zabbix。你需要编辑zabbix的配置文件(通常位于`/usr/local/zabbix/etc/zabbix_server.conf`)并设置数据库信息、Nginx等相关配置。 7. 启动服务。你可以使用以下命令启动Nginx、MySQL和zabbix服务: ``` systemctl start nginx systemctl start mysql systemctl start zabbix-server systemctl start zabbix-agent ``` 请注意,以上步骤只是一个基本的指导,具体的操作可能因为你的环境和需求而不同。在实际操作中,请确保你已经阅读并理解相关文档并根据需要进行适当调整。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [银河麒麟系统v10安装zabbix(mariadb篇)及踩坑排雷总结](https://blog.csdn.net/Kaylee_123/article/details/119893139)[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_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值