c ++的新手,用其他语言编写了几年。 我一整天都陷入了这个问题,我似乎无法弄明白。
当我运行此处发布的代码时:http://www.nongnu.org/fastcgipp/doc/2.1/a00004.html 我收到以下错误消息:
加载共享库时出现错误:libfastcgipp.so.2:无法打开 共享对象文件:没有这样的文件或目录
使用ubuntu 13.10
我可以构建没有问题的代码,但不能运行它。 libfastcgipp.so.2
libfastcgipp.so
和/usr/local/lib/
我尝试从/usr/lib/libfastcgipp.so
来自ldd命令的结果......
ldd joppli.bot.dummy
linux-vdso.so.1 => (0x00007fff497fe000)
libboost_system.so.1.53.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0 (0x00007f8b1828f000)
libboost_thread.so.1.53.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.53.0 (0x00007f8b18079000)
libfastcgipp.so.2 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8b17d74000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8b17b5e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8b17795000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8b1758d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8b17370000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8b1706b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8b184b6000)
答案 0 :(得分:1)
我通过如上所述创建文件的符号链接来解决了这个问题,但最后添加了结尾编号2
,版本号。
例如:ln -s /usr/local/lib/libfastcgipp.so.2.0.0 /usr/lib/libfastcgipp.so.2
再次讨论这个问题并且无法再次找出同样的问题,所以我发布了一个docker文件,它将使你的fastCGI ++脚本运行(可能只有我会使用它,但无论如何...)
fastcgi ++ 2.1来源:http://www.nongnu.org/fastcgipp/
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN ln -snf /usr/share/zoneinfo/Europe/Stockholm /etc/localtime \
&& echo "Europe/Stockholm" > /etc/timezone
ENV TERM xterm
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse" >> /etc/apt/sources.list
RUN echo "deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse" >> /etc/apt/sources.list
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse" >> /etc/apt/sources.list
RUN echo "deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse" >> /etc/apt/sources.list
RUN apt-get -y update && apt-get -y install \
build-essential \
libboost-all-dev \
git \
apache2 \
libapache2-mod-fastcgi
COPY dependencies/fastcgi++-2.1.tar.bz2 /tmp/fastcgi++-2.1.tar.bz2
RUN cd /tmp \
&& tar xvf fastcgi++-2.1.tar.bz2 \
&& cd fastcgi++-2.1 \
&& ./configure \
&& make \
&& make install
RUN ln -s /usr/local/lib/libfastcgipp.so.2.0.0 /usr/lib/libfastcgipp.so.2
COPY rep /tmp/app
RUN cd /tmp/app \
&& g++ main.cpp -o example -std=gnu++11 -lfastcgipp -lboost_system -lboost_thread \
&& mv example /var/www/example
COPY config/apache/default.conf /etc/apache2/sites-available/example.conf
COPY config/apache/.htaccess /var/www/.htaccess
RUN mkdir -p /tmp/log/apache/
RUN a2enmod rewrite
RUN a2dissite 000-default
RUN a2ensite example.conf
RUN service apache2 restart
RUN apt-get autoremove -y && apt-get clean all
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
<强>配置/阿帕奇/ default.conf 强>
ServerName example
<VirtualHost *:80>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
SetHandler fastcgi-script
<Directory "/var/www">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /tmp/log/apache/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /tmp/log/apache/access.log combined
</VirtualHost>
<强>的.htaccess 强>
RewriteEngine On
RewriteRule (.+)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ example [NC,L]
DirectoryIndex example