CentOS查服务器配置、关防火墙、改DNS、mysql配置问题集锦、CentOS编译PHP5.6常见错误

本文介绍如何查看CentOS服务器的配置信息,包括CPU、内存等,并提供了解决MySQL配置问题的方法,同时涵盖了PHP5.6编译过程中可能遇到的错误及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CentOS 查看服务器配置信息

查看CPU型号

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     32  Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz

查看物理CPU的个数

cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l
2

查看逻辑CPU的个数

cat /proc/cpuinfo |grep "processor"|wc -l
32

查看CPU是几核

cat /proc/cpuinfo |grep "cores"|uniq
cpu cores       : 8

还可以用:lscpu

查看内存:free -m

查看机器牌子型号:dmidecode | grep "Product Name"
        Product Name: IBM System x3650 M4: -[7915SZO]-
        Product Name: 00MV214

查看硬盘:lvs


关防火墙

setenforce  0

查看host文件

cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
ip 主机名

改DNS


手工修改:vi  /etc/resolv.conf

-----------------------------------------------------------------------------

另外也可以继续使用/etc/resolv.conf

  • 修改 /etc/NetworkManager/NetworkManager.conf 文件,在main部分添加 “dns=none” 选项:
  • [main]
    plugins=ifcfg-rh
    dns=none
    • 手工修改 /etc/resolv.conf
    重启网卡

    systemctl restart NetworkManager.service
    -----------------------------------------------------------------------------

mysql配置问题集锦

一、启动MySQL服务的时候,日志报下面警告:

[Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 15000)

[Warning] Buffered warning: Changed limits: max_connections: 214 (requested 3000)

[Warning] Buffered warning: Changed limits: table_open_cache: 400 (requested 2000)

解决:

首先在文件sudo vi/etc/security/limits.conf中追加下面信息:(重新登录后limit.conf的配置都不生效,后来发现,ubuntu有个bug,root用户必须注明用户)

*           soft   nofile       655350
*           hard   nofile       655350
*           hard   nproc        655350
*           soft   nproc        655350
root soft nofile 655350
root hard nofile 655350

重新连接一下就可以看到了,ulimit -a

重启mysql服务,问题解决。如果发现日志还报警告。

centos7系统:

vim /etc/systemd/system/mysql.service

加入 LimitNOFILE=65535

重启mysql服务,问题解决。

二、TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

vi my.cnf
explicit_defaults_for_timestamp= true

三、kip-name-resolve 参数的目的是不再进行反解析(ip不反解成域名),这样可以加快数据库的反应时间。

修改配置文件添加并需要重启:

[mysqld] 

skip-name-resolve

添加后发现错误日志有警告信息
131127 11:09:12 [Warning] 'user' entry 'root@cvs' ignored in --skip-name-resolve mode.
131127 11:09:12 [Warning] 'user' entry '@cvs' ignored in --skip-name-resolve mode.
131127 11:09:12 [Warning] 'proxies_priv' entry '@ root@cvs' ignored in --skip-name-resolve mode
启用后,在mysql的授权表中就不能使用主机名了,只能使用IP ,出现此警告是由于mysql.user表中已经存在有相关的帐号信息。 我们把它删除就好了
mysql>use mysql; 
mysql> delete  from user where HOST='cvs'; 
Query OK, 2 rows affected (0.00 sec)   

然后删除表mysql.proxies_priv中和cvs类似与具体域名有关的行,方法同上。

重启MYSQL ,发现警告已经没有啦。 


四、运行sql时报错:

ERROR 2006 (HY000): MySQL server has gone away

更改:

vi /etc/my.cnf

max_allowed_packet = 128M

wait_timeout = 180
interactive_timeout = 180

重启数据库

systemctl restart mysqld


CentOS编译PHP5.6过程中常见错误信息的解决方法


以下是具体的一些解决办法:

*******************************************************************************

checking for BZip2 support… yes checking  for BZip2 in default path… not found configure: error: Please reinstall the  BZip2 distribution

解决方法: yum install  bzip2-devel

*******************************************************************************

checking for cURL support… yes checking  if we should use cURL for url streams… no checking for cURL in default path…  not found configure: error: Please reinstall the libcurl distribution –  easy.h should be in/include/curl/

解决方法: yum install  curl-devel

*******************************************************************************

checking for curl_multi_strerror in  -lcurl… yes checking for QDBM support… no checking for GDBM support… no  checking for NDBM support… no configure: error: DBA: Could not find necessary  header file(s).

解决方法: yum install  db4-devel

*******************************************************************************

checking for fabsf… yes checking for  floorf… yes configure: error: jpeglib.h not found.

解决方法: yum install  libjpeg-devel

*******************************************************************************

checking for fabsf… yes checking for  floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error:  png.h not found.

解决方法: yum install  libpng-devel

*******************************************************************************

checking for png_write_image in -lpng…  yes If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.

解决方法: Reconfigure your  PHP with the following option. --with-xpm-dir=/usr

*******************************************************************************

Configure: error: freetype.h not found. 

的解决办法:yum install freetype-devel

*******************************************************************************

checking for png_write_image in -lpng…  yes configure: error: libXpm.(a|so) not found.

解决方法: yum install  libXpm-devel

*******************************************************************************

checking for bind_textdomain_codeset in  -lc… yes checking for GNU MP support… yes configure: error: Unable to locate  gmp.h

解决方法: yum install  gmp-devel

*******************************************************************************

checking for utf8_mime2text signature…  new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new  signature, but U8T_CANONICAL is missing. This should not happen. Check  config.log for additional information.

解决方法: yum install  libc-client-devel

*******************************************************************************

checking for LDAP support… yes, shared  checking for LDAP Cyrus SASL support… yes configure: error: Cannot find  ldap.h

解决方法: yum install  openldap-devel

*******************************************************************************

checking for mysql_set_character_set in  -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no  checking for Oracle Database OCI8 support… no checking for unixODBC support…  configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

解决方法:yum install  unixODBC-devel

*******************************************************************************

checking for PostgreSQL support for PDO…  yes, shared checking for pg_config… not found configure: error: Cannot find  libpq-fe.h. Please specify correct PostgreSQL installation path

解决方法: yum install  postgresql-devel

*******************************************************************************

checking for sqlite 3 support for PDO…  yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext  checking for sqlite3 files in default path… not found configure: error:  Please reinstall the sqlite3 distribution

解决方法: yum install  sqlite-devel

*******************************************************************************

checking for utsname.domainname… yes  checking for PSPELL support… yes configure: error: Cannot find pspell

解决方法: yum install  aspell-devel

*******************************************************************************

checking whether to enable UCD SNMP hack…  yes checking for default_store.h… no

checking for kstat_read in -lkstat… no  checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp…  no configure: error: SNMP sanity check failed. Please check config.log for  more information.

解决方法: yum install  net-snmp-devel

*******************************************************************************

checking whether to enable XMLWriter  support… yes, shared checking for xml2-config path… (cached)  /usr/bin/xml2-config checking whether libxml build works… (cached) yes  checking for XSL support… yes, shared configure: error: xslt-config not  found. Please reinstall the libxslt >= 1.1.0 distribution

解决方法: yum install  libxslt-devel

*******************************************************************************

configure: error: xml2-config not found.  Please check your libxml2 installation.

解决方法: yum install libxml2-devel

*******************************************************************************

checking for PCRE headers location…  configure: error: Could not find pcre.h in /usr

解决方法: yum install  pcre-devel

*******************************************************************************

configure: error: Cannot find MySQL  header files under yes. Note that the MySQL client library is not bundled  anymore!

解决方法: yum install  mysql-devel

*******************************************************************************

checking for unixODBC support… configure:  error: ODBC header file ‘/usr/include/sqlext.h’ not found!

解决方法: yum install  unixODBC-devel

*******************************************************************************

checking for pg_config… not found  configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL  installation path

解决方法:yum install  postgresql-devel

*******************************************************************************

configure: error: Cannot find pspell

解决方法: yum install  pspell-devel

*******************************************************************************

configure: error: Could not find  net-snmp-config binary. Please check your net-snmp installation.

解决方法: yum install  net-snmp-devel

*******************************************************************************

configure: error: xslt-config not found.  Please reinstall the libxslt >= 1.1.0 distribution

解决方法: yum install  libxslt-devel

*******************************************************************************

configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
复制代码 代码如下:
yum -y install libicu-devel

*******************************************************************************

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

yum  install  php-mcrypt  libmcrypt  libmcrypt-devel  
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.sohu.com
 * extras: mirrors.163.com
 * updates: mirrors.neusoft.edu.cn
没有可用软件包 php-mcrypt。
没有可用软件包 libmcrypt。
没有可用软件包 libmcrypt-devel。
错误:无须任何处理

CentOS源不能安装libmcrypt-devel,由于版权的原因没有自带mcrypt的包。

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
mkdir /usr/local/libmcrypt
./configure --prefix=/usr/local/libmcrypt
make
make install

--with-mcrypt=/usr/local/libmcrypt

*******************************************************************************

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/    
    
yum install curl curl-devel         


If configure fails try --with-vpx-dir=<DIR>
configure: error: jpeglib.h not found.               


yum install  libjpeg-devel                        


checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.           


yum install libpng       
                        
yum install libpng-devel                 


If configure fails try --with-xpm-dir=<DIR> 
configure: error: freetype-config not found.         


yum install freetype-devel


configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.         


yum -y install libicu-devel


configure: error: mcrypt.h not found. Please reinstall libmcrypt.       


yum install libmcrypt libmcrypt-devel 


关防火墙

systemctl stop firewalld.service
systemctl start firewalld.service
systemctl restart iptables.service
<think>首先,用户的问题是:"我想解决Vue2项目中Networkunavailable的问题请问Vue2Networkunavailable解决方案"。这是一个关于Vue.js开发中常见的问题,其中在运行项目时,Network显示为unavailable,意味着无法通过本地网络访问项目。从系统级指令,我需要:-所有行内数学表达式用$...$格式(但在这个问题中,可能不涉及数学,所以可能不需要)。-独立公式用$$...$$(同样,可能不适用)。-LaTeX语法正确。-使用中文回答。-生成相关问题。-在回答中引用的段落末尾添加引用标识,如[^1]。用户可见层的要求:-回答结构清晰,逐步解决问题。-保证回答真实可靠。参考的站内引用提供了几个解决方案:-引用[1]:提到了三种情况:多个网卡、配置host和public、系统环境变量问题。给出了在vue.config.js中配置devServer的方法。-引用[2]:类似,强调配置public字段和检查IP地址。-引用[3]:专注于系统环境变量,添加C:\Windows\System32\Wbem到Path。-引用[4]:再次提到在devServer中添加public。-引用[5]:建议在devServer中配置public和disableHostCheck。关键点总结:1.**多个网卡问题**:禁用多余的网络适配器。2.**配置host和public**:在vue.config.js文件中设置devServer的host和public。3.**系统环境变量问题**:添加C:\Windows\System32\Wbem到Path环境变量。我的回答应该结构清晰:-先解释问题:为什么Network显示unavailable?-然后分步给出解决方案。-确保解决方案可靠,基于引用。结构建议:1.**引言**:简述问题。2.**常见原因**:列出可能导致问题的原因。3.**解决方案**:分步骤详细说明。4.**验证**:如何确认问题解决。5.**相关问题**:生成几个相关问题。生成相关问题:-基于主题,例如:1.如何查找本机IP地址?2.Vue2项目中devServer的其他配置选项?3.如果环境变量修改无效,还有什么其他方法?确保使用中文回答。最终回答框架:-**问题描述**:Vue2项目运行npmrunserve后,Network显示unavailable,无法通过IP访问。-**原因分析**:通常由于网络配置、VuedevServer设置或系统环境问题。-**解决方案**:a.**检查网络适配器**:禁用多余网卡。b.**配置vue.config.js**:设置devServer的host和public。c.**修改环境变量**:添加Wbem路径到Path。-**步骤详解**:每一步给出具体操作。-**相关问题**:在末尾添加。引用标识:在引用内容后添加[^1],[^2]等,但引用是来自用户提供的,所以我应该引用那些内容。</think>### Vue2项目中Network: unavailable解决方案 在Vue2项目中运行`npm run serve`后出现**Network: unavailable**问题,表示项目无法通过本地网络IP访问(只能通过`localhost`访问)。这通常由网络配置冲突、Vue开发服务器设置不当或系统环境变量问题引起。以下是基于可靠实践的分步解决方案(参考社区常见修复方法[^1][^2][^3][^4][^5])。 --- ### 原因分析 - **多个网络适配器冲突**:电脑有多个网卡(如Wi-Fi、以太网、虚拟机网卡),导致Vue无法正确绑定IP[^1][^2]。 - **devServer配置缺失**:Vue的`devServer`未指定`public`字段或IP地址错误[^1][^4][^5]。 - **系统环境变量异常**:缺少`C:\Windows\System32\Wbem`路径,影响网络管理功能[^1][^3][^5]。 ### 分步解决方案 按照以下步骤操作,问题通常可解决(优先尝试方法1,若无效再逐步排查)。 #### 方法1: 配置Vue项目的devServer(推荐) 此方法直接修改Vue开发服务器设置,确保绑定正确IP。 1. **查找本机IP地址**: - 方法A:按`Win+R`,输入`cmd`打开命令提示符,执行`ipconfig`,找到`IPv4地址`(如`192.168.1.2`)[^2][^4]。 - 方法B:在“控制面板 > 网络和共享中心 > 网络连接”中查看活动网络的IPv4地址[^2]。 2. **修改vue.config.js文件**: -Vue项目根目录下创建或编辑`vue.config.js`文件。 - 添加以下配置(替换`public`值为你的IP和端口): ```javascript module.exports = { devServer: { host: '0.0.0.0', // 允许所有主机访问 public: '192.168.1.2:8080', // 改为你的IP和端口(如192.168.1.2:8080) port: '8080', // 端口号 https: false, // 禁用HTTPS disableHostCheck: true, // 关闭主机检查 open: false // 不自动打开浏览器 } }; ``` - **注意**:`public`字段必须与`ipconfig`显示的IP一致;如果网络切换(如从Wi-Fi换到热点),需更新IP[^2][^4][^5]。 3. **重启项目**: - 在VSCode终端运行: ```bash npm run serve ``` - 检查终端输出,Network应显示可用IP(如`http://192.168.1.2:8080`)。 #### 方法2: 禁用多余网络适配器 如果多个网卡导致冲突,精简网络配置。 1. 打开“控制面板 > 网络和共享中心 > 更改适配器设置”。 2. 禁用所有未使用的网络连接(如虚拟机网卡、蓝牙网络),只保留当前活动的连接(如Wi-Fi)[^1][^2]。 3. 重启VSCode并重新运行`npm run serve`。 #### 方法3: 修复系统环境变量 若上述无效,可能是系统Path变量缺失关键路径。 1. 打开环境变量设置: - `Win+R`输入`sysdm.cpl` → 高级 → 环境变量。 - 或在“设置 > 系统 > 高级系统设置”中找到[^3]。 2. 编辑系统变量: - 在“系统变量”列表中选择`Path` → 点击“编辑”。 - 添加新条目:`C:\Windows\System32\Wbem`(确保无拼写错误)[^1][^3][^5]。 3. 保存并重启: - 保存所有更改,重启电脑(或至少重启VSCode)。 - 重新运行项目,查看Network状态。 --- ### 验证问题解决 - **成功标志**:终端运行`npm run serve`后,Network显示类似`Network: http://192.168.1.2:8080`。 - **测试访问**:在同一局域网的手机或其他电脑,浏览器输入`http://<你的IP>:8080`,应能访问项目- **常见失败原因**: - IP地址错误:确保`public`字段IP与`ipconfig`一致[^4]。 - 防火墙阻拦:临时禁用防火墙测试。 - Vue版本问题:Vue CLI需更新至最新(运行`npm update -g @vue/cli`)。 > **注意**:这些方法基于Vue社区常见实践,成功率较高。如果问题持续,建议检查项目依赖(`npm install`)或操作系统更新[^1][^3][^5]。 --- ### 相关问题 1. **如何查找本机的准确IP地址?** 2. **Vue2的devServer还有哪些常用配置选项?** 3. **如果环境变量修复无效,还有什么其他解决方案?** 4. **Network: unavailable问题是否在Vue3中也存在?如何解决?** [^1]: 多个网卡原因或环境变量问题可能导致此错误,需禁用多余网络或添加Wbem路径到Path变量。 [^2]: 配置devServer的public字段是关键,IP地址需通过ipconfig或网络中心获取。 [^3]: 系统环境变量中添加C:\Windows\System32\Wbem可修复网络管理功能缺失。 [^4]: public字段必须与当前网络IP一致,切换网络后需更新。 [^5]: 在devServer中设置disableHostCheck: true有助于绕过主机检查。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值