pcre编译安装
❶ linux编译安装apache httpd2.4 make报错
缺少pcre-8.41.tar.gz包,找一个pcre和你httpd对应得版本安装
./configure --prefix=/usr/local/pcre
make && make install
安装好了之后,加上参数--with-pcre=/usr/local/pcre 如下所示
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
❷ linux编译安装命令
Linux编译安装相关命令,下面以Linux安装Mysql工具为例进行说明,代码如下:
1、测试环境在Linux MySQL下进行,版本系统为CentOS5,以下为相关软件:
mysql-5.1.30
memcached-1.2.6
libevent-1.4.7-stable
memcached_functions_mysql-0.8
libmemcached-0.26
2、编译安装Linux MySQL
[root@localhost~]#tarxzfmysql-5.1.30.tar_001.gz
[root@localhost~]#cdmysql-5.1.30
[root@localhost~]#./configure--prefix=/usr/local/mysql51
[root@localhost~]#make
[root@localhost~]#makeinstall
[root@localhost~]#./scripts/mysql_install_db--user=mysql--skip-name-resolve
[root@localhost~]#/usr/local/mysql51/bin/mysqld_safe
#连接符&这是放入后台,&&是前一个正确执行,才会执行后一个
#Linux编译安装流程./configure&&make&&makeinstall(默认目录安装)
#./configure--prefix=/usr/local/pcre&&make&&makeinstall(指定安装目录)
❸ 如何在线安装pcre
PCRE的安装及使用
1、主页地址:www pcre org 下载pcre-8.13 tar bz2
2、解压缩: tar xjpf pcre-8.13 tar bz2
3、配置: cd pcre-8.13 ./configure --prefix=/usr/local/pcre-8.13 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre configure有许多参数可配,具体参见./configure --help及手册
4、编译: make
5、安装: make install
6、将库文件导入cache: 方法1:在/etc/ld.so.conf中加入: /usr/local/lib/pcre,然后运行ldconfig 方法2:在/etc/ld.so.conf.d/下新生成一个文件(或在其中的文件中加入同样内容),文件内容为: /usr/local/lib/pcre,然后运行ldconfig
7、编译自带的demo程序 gcc -Wall pcredemo.c -I/usr/local/include/pcre -L/usr/local/lib/pcre -lpcre -o pcredemo
8、执行 ./pcredemo -g 'cat|dog' 'the dog sat on the cat' ./pcredemo 'cat|dog' 'the cat sat on the mat' 安装过程遇到的问题,在ubuntu 10.04下,如果直接./configure;make;make intall的话,默认安装的目录是/usr/local/,但是,即使用 gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre -o pcredemo 编译,执行时会出现./pcredemo: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory 错误的原因是没用用ldconfig加载库文件到cache。只需按第6步将库文件加载到cache就行
❹ nginx编译安装需要哪些库
如果有网的情况,不用管这些。进入你的nginx文件夹,进行以下操作:
通常至少需要以下库:
pcre(正则) , gcc(C编译器) , net-tools(使用netstat命令)。
一般有了上述的库就能完成编译,如果还不行,运行
./configure --prefix=你希望安装到的目录
命令,最下方提示error少了什么库,你就 yum -y install 库名(错误的提示里面)就可以自动下载安装了。
❺ centos7怎么编译安装nginx
安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install
如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++
如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解决方法:
yum install pcre-devel
如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
yum install openssl-devel
以上错误提示依次解决后:再一次的运行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install
编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_mole
#开启ssl支持
--with-http_ssl_mole
#开启GZIP功能
--with-http_gzip_static_mole
因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel
2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方法:
/usr/local/nginx/sbin/nginx
但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=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 -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl的一些使用方法:
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable xxx.service #开机运行服务
systemctl disable xxx.service #取消开机运行
systemctl start xxx.service #启动服务
systemctl stop xxx.service #停止服务
systemctl restart xxx.service #重启服务
systemctl reload xxx.service #重新加载服务配置文件
systemctl status xxx.service #查询服务运行状态
systemctl --failed #显示启动失败的服务
因此,添加上面脚本后,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查询nginx是否开机启动
systemctl enable nginx.service #开机运行nginx
systemctl disable nginx.service #取消开机运行nginx
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl reload nginx.service #重新加载nginx配置文件
systemctl status nginx.service #查询nginx运行状态
systemctl --failed #显示启动失败的服务
❻ linux下如果把pcre库卸载了,会出现什么后果
Linux下PCRE是一个Perl库,包括perl兼容的正则表达式库,在执行正规表达式模式匹配时用与Perl5同样的语法和语义是很有用的,删除后会出现部分命令不能使用,可以重新安装,方法如下:
1.下载PCRE包,首先去官网下载pcre的安装包
下载地址为:http://sourceforge.net/projects/pcre/files/pcre/
2.把安装包解压
[root@localhostlocal]#tar-zxvfpcre-8.32.tar.gz
3.解压之后在当前目录下生成了一个文件夹:pcre-8.32
drwxr-xr-x7116911694096Nov3018:50pcre-8.32
4.配置
[[email protected]]#./configure
5.编译,执行make操作:
[[email protected]]#make
6.安装,执行make install操作:
[[email protected]]#makeinstall
make install结束后pcre编译安装流程就结束了。
❼ 怎么检查 linux是否安装 pcre
1、连接上相应的linux主机,进入到等待输入shell指令的linux命令行状态下。
❽ Linux系统pcre编译安装,系统自带pcre-8.32-15.el7.x86_64 ,我现在需要安装最新版 pcre-8.39.tar.gz,
你通过make install安装的软件包是不能通过rpm查看到的
rpm只能查看用rpm方式安装的软件
❾ 如何在Windows下通过Cmake编译和使用PCRE
CMake是一个比make更高级的编译配置工具,它可以根据不同平台、不同的编译器,生成相应的Makefile或者vcproj项目。
通过编写CMakeLists.txt,可以控制生成的Makefile,从而控制编译过程。CMake自动生成的Makefile不仅可以通过make命令构建项目生成目标文件,还支持安装(make install)、测试安装的程序是否能正确执行(make test,或者ctest)、生成当前平台的安装包(make package)、生成源码包(make package_source)、产生Dashboard显示数据并上传等高级功能,只要在CMakeLists.txt中简单配置,就可以完成很多复杂的功能,包括写测试用例。
如果有嵌套目录,子目录下可以有自己的CMakeLists.txt。
总之,CMake是一个非常强大的编译自动配置工具,支持各种平台,KDE也是用它编译的,感兴趣的可以试用一下。
准备活动:
(1)安装cmake。
下载地址:
根据自己的需要下载相应的包即可,Windows下可以下载zip压缩的绿色版本,还可以下载源代码。
Windows下CMake的使用
(2)运行cmake的方法。(GUI、命令行)
CMake使用步骤:
运行GUI的cmake界面:
cmake-2.8.1-win32-x86\bin\cmake-gui.exe
Windows下CMake的使用
执行Configure:
运行之后,生成了如下文件:
Windows下CMake的使用
生成Makefile:
执行Generate之后生成如下文件:
Windows下CMake的使用
运行make进行编译:
Windows下CMake的使用
编译完成后,在build目录生成Tutorial.exe,运行Tutorial.exe 25就可以看到运行结果:
Windows下CMake的使用
运行make install安装程序:
Windows下CMake的使用
运行make test进行测试:
Windows下CMake的使用
通过cmake tutorial学习CMake配置方法
可以在源代码的Tests/Turorial目录中找到这个手册对应的代码。
Windows下CMake的使用
1、Step1。
(如果不知道如何使用cmake,以及如何使用编译产生的Turorial.exe,可先看下前面“CMake使用步骤”的说明,它以Step4为例详细介绍了使用过程,Step1的配置可能不够完全,比如无法运行make install,无法运行make test,但可以参考。)
简单的程序编译。
(1)运行GUI的cmake,指定要编译的源代码路径和二进制文件路径(会自动创建)。
Windows下CMake的使用
(2)点击Configure,配置成功后,再点击Generate。
配置需要选择合适的编译器,虽然我安装了VC2008,但没有配置成功;选择Unix Makefiles,配置成功,它自动找到了DevC++下的gcc.exe等编译器。
Windows下CMake的使用
(3)在build3目录执行make,就能够编译生成Turorial.exe了。
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>make
Linking CXX executable Tutorial.exe
[100%] Built target Tutorial
可以运行一下Turorial.exe:
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>Tutorial.exe
Tutorial.exe Version 1.0
Usage: Tutorial.exe number
D:\Projects\Lab\testngpp\cmake-2.8.1\Tests\Tutorial\Step1\build3>Tutorial.exe 4
The square root of 4 is 2
2、Step2
把子目录编译为库,并且链接到最终的可执行文件。
include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
add_subdirectory (MathFunctions) # 使得子目录MathFunctions也能被编译
# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial MathFunctions)
产生makefile:
在GUI上点击Configure,之后Generate还是灰色,再次点击Configure,Generate就可以点击了。
编译:
❿ 怎么编译安装nginx1.8.1
要编译安装Nginx,首先我们要安装依赖包 pcre-devel 和 zlib-devel:
# yum install pcre-devel zlib-devel -y
程序默认是使用 nobody 身份运行的,我们建议使用 nginx 用户来运行,首先添加Nginx组和用户,不创建家目录,不允许登陆系统
# groupadd nginx
# useradd -M -s /sbin/nologin -g nginx nginx
准备工作完成后就是下载编译安装Nginx了,可以从我提供的网盘下载,也可以去Nginx的官网下载。
首先解压源码包:
# tar xf nginx-1.4.4.tar.gz
然后 cd 到解压后的目录就可以执行 ./configure 了
# cd nginx-1.4.4
指定安装目录和运行时用的属主和属组,并启用状态监控模块等
# ./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_mole \
--with-http_flv_mole \
--with-http_stub_status_mole \
--with-http_gzip_static_mole \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
等配置完成后就可以 make && make install 了
# make && make install
# mkdir /var/tmp/nginx/client/ -pv
等编译安装完成后在 /usr/local 下就会出现 Nginx 这个目录了,进入这个目录后发现目录非常简单。它的配置文件存放在 conf 目录中,网页文件存放在 html 中,日志文件存放在 logs 中,sbin 目录下只有一个可执行程序 "nginx"
接下来我们简单的为它提供一个服务脚本吧!
# vim /etc/init.d/nginx
新建文件/etc/rc.d/init.d/nginx,内容如下:
#!/bin/bash
# chkconfig:235 85 15
# description: Nginx is an HTTP server
. /etc/rc.d/init.d/functions
start() {
echo "Start..."
/usr/local/nginx/sbin/nginx &> /dev/null
if [ $? -eq 0 ];then
echo "Start successful!"
else
echo "Start failed!"
fi
}
stop() {
if killproc nginx -QUIT ;then
echo "Stopping..."
fi
}
restart() {
stop
sleep 1
start
}
reload() {
killproc nginx -HUP
echo "Reloading..."
}
configtest() {
/usr/local/nginx/sbin/nginx -t
}
case $1 in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
reload)
reload ;;
configtest)
configtest ;;
*)
echo "Usage: nginx {start|stop|restart|reload|configtest}"
;;
esac
之后给这个文件可执行权限:
# chmod +x /etc/init.d/nginx
好了,现在可以使用 start,stop 这些参数控制Nginx服务了
由于脚本是我自己写的,还有许多不尽人意的地方,欢迎大家修改和完善!
现在我们就试试启动服务看看效果吧:
# service nginx start
记得关闭 SElinux 和 iptables 防火墙哦,
# service iptables stop
# setenforce 0
接下来就在浏览器中访问你服务的IP看看效果吧!是不是出项了欢迎的字样呢
接下来就研究下 Nginx 的配置文件吧!
# vim /usr/local/nginx/conf/nginx.conf
各项参数的意义如下:
worker_processes 1; 工作进程数量
error_log logs/error.log; 日志文件位置
pid logs/nginx.pid; pid文件位置
worker_connections 1024; 没进程的连接数
listen 80; 监听端口
server_name localhost; 主机名
root html; 网站根目录
index index.html index.htm; 网站索引页
error_page 500 502 503 504 /50x.html; 访问错误页面
剩下的其他被注释掉的代码块:
location ~ \.php$ { . . . . . . } 对PHP的支持,需要安装PHP
server { . . . . . . } 添加server代码块能添加虚拟主机
剩下还有监听443端口的超文本传输安全协议 HTTPS server 需要在编译Nginx时添加ssl的支持
接下来我们试着添加一台虚拟主机吧,虚拟主机的添加可以基于端口,可以基于IP,也可以基于主机名,我们挨个来看看:
基于端口:
首先编辑配置文件,添加server代码块,记得要写到http{ . . . . . . }这个大的代码块中。
server {
listen 8080;
server_name localhost;
location / {
root /var/www/html;
index index.html index.htm;
}
}
这样就添加了一个监听8080端口的服务,你也可以定义自己喜欢的端口哦。
接下来检查下配置文件有没有问题,如果最后一个单词显示successful就代表没问题了,可以重新启动Nginx了
# service nginx configtest
# service nginx restart
接下来就给第二个虚拟主机写一个index吧!首先创建目录
# mkdir -pv /var/www/html
# echo '<h1>Hi! This is 8080!</h1>' > /var/www/html/index.html
好了 接下来试着在浏览器中访问访问,记得第二个主机要加上端口访问哦
现在试着用不同的IP建立虚拟主机吧!我们可以在一块网卡上绑定多个IP地址的方式来实现
# ifconfig eth0:0 10.0.0.4/8
记得把IP换成你自己的哦!然后ifconfig看看是不是多出来一个网卡IP了呢
让后继续修改配置文件,这回要修改两个地方,一个是原本自带的站点的 listen 项,一个是自己添加的站点的 listen 项。
基于IP:
server {
listen 10.0.0.3:80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 10.0.0.4:80;
server_name localhost;
location / {
root /var/www/html;
index index.html index.htm;
}
}
让他们只监听不同的IP,用相同的端口
接下来再浏览器上用不同的IP来访问试试吧,及的还得重启Nginx,先检查一下,出现错误了看看哪里配置的不对,然后就可以重启了。
# service nginx congiftest
# service nginx restart
如果配置给网卡的第二个IP不想要了,把它停掉就可以了
# ifconfig eth0:0 down
再 ifconfig 看看是不是没有了呢
现在试试用不同的主机名吧!也是企业用的最多的方式。我们把两个站点的listen项都改为80,然后修改service_name项为定义的主机名
基于主机名:
server {
listen 80;
server_name ybmq.com;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 80;
server_name zhzz.com;
location / {
root /var/www/html;
index index.html index.htm;
}
}
然后重启Nginx吧!
可是我们在浏览器上怎么通过域名访问呢?要知道我们访问 啊,qq 啊之类的是通过DNS服务器的,难道我们还要配置一台DNS服务器?其实不然,我们通过修改客户机的 hosts 文件就可以了。hosts文件是一个本地的域名解析文件,我们要解析哪些域名只要把域名和对应的IP写到一起就可以了。在Windows XP之后的系统中,这个文件位于:
C:\Windows\System32\drivers\etc\hosts
我们用文本编辑器打开,添加两个相同的IP对应的两个不同的主机名就可以了。
如下图所示
如果你打开这个文件发现已经有很多IP地址了,可以直接在最后加入这两行,也可以直接清空这个文件,不会有什么问题的。这个文件的用途还可以屏蔽一些网站哦,只需要把网址对于的IP改为 127.0.0.1 也就是本地回环地址,浏览器查询域名对应的IP时时先通过查询这个文件的,如果查询到了,不管对错都不会访问DNS服务器了,所以我们给它一个错误的地址,那它一辈子也打不开被屏蔽掉的网站了。
好了 接下来就在浏览器中试试用用域名访问你的两个站点吧。
如果大家还用IP访问会是什么情况呢?我不说了,大家还是自己测试吧 哈哈o(^▽^)o