gcc 编译错误,和架设web注意点

gcc xx.c -o abc -lxxx

的时候出现如下错误:
/usr/bin/ld: cannot find -lxxx
collect2: ld returned 1 exit status
 
原因:gcc找不到需要链接的lib
解决方案:
1. 不要用 -l ,而直接把libmysqlclient作为一个编译组件列在后面
2.把libmysqlclient.so放在系统标准路径里面
3.或者修改/etc/ld.so.conf文件,把其所在目录加进去;别忘记运行一次ldconfig更新缓存
4.export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xxx/lib  ->the path of your lib
 

http://php.net/downloads.php

sudo yum install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel
tar -jxvf php-5.3.6.tar.bz2
cd php-5.3.6
./configure --prefix=/opt/php -with-apxs2=/opt/httpd/bin/apxs --with-curl --with-mcrypt --enable-mbstring --with-iconv --with-gd -with-jpeg-dir=/usr/local/lib --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
make
sudo make install
sudo cp php.ini-development /opt/php/lib/php.ini
sudo ln -s /opt/php/bin/php /usr/bin/php
sudo vi /opt/php/lib/php.ini

把include_path前面的分号删除,改成include_path = "/opt/php/lib/php"
sudo vi /opt/httpd/conf/httpd.conf
在最下面加入一行AddHandler application/x-httpd-php .php
sudo /opt/httpd/bin/httpd -k restart
sudo vi /opt/httpd/htdocs/phpinfo.php

phpinfo.php的内容如下:

<?php
phpinfo();
?>

安装完php,重启apache,用浏览器访问http://localhost/phpinfo.php,能正常显示说明php装好了。搜索mysqlnd、pdo_mysql、mysqli,如果有,则说明php能访问mysql。

把apache加入系统service,开机自启动

sudo cp /opt/httpd/bin/apachectl /etc/init.d/httpd
sudo vi /etc/init.d/httpd
在文件开头加入下面几行:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server. 
sudo chmod +x /etc/init.d/httpd
sudo /sbin/chkconfig --add httpd
sudo /sbin/chkconfig --list httpd
sudo ln -s /sbin/chkconfig /usr/bin/chkconfig
sudo ln -s /sbin/service /usr/bin/service

把mysql加入系统service,开机自启动

sudo /sbin/chkconfig --list mysql

通过rpm安装的mysql,已经开机自启动了。

安装php扩展ssh2

先安装libssh2

http://sourceforge.net/projects/libssh2/

./configure

make

sudo make install

再安装ssh2

http://pecl.php.net/package/ssh2

/opt/php/bin/phpize && ./configure --with-ssh2 && make

sudo make install

在/opt/php/lib/php.ini中加1行:

extension=ssh2.so

centos php升级:

先修改更新源为国内的更新源

cd /etc/yum.repos.d
sudo mv CentOS-Base.repo CentOS-Base.repo.save
sudo wget http://centos.ustc.edu.cn/CentOS-Base.repo

清理残留文件然后更新标准库,再升级

sudo yum clean all
sudo yum update glibc\*
sudo yum update yum\* rpm\* python\*
sudo yum clean all
sudo yum update
sudo reboot

Linux 设置服务器时区 UTC 0区

Linux服务器使用UTC 0区Atlantic/Reykjavik,这样各个程序都比较简单,时间不用算来算去的。

sudo tzselect
 6) Atlantic Ocean
6
5) Iceland
5
You can make this change permanent for yourself by appending the line
	TZ='Atlantic/Reykjavik'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Atlantic/Reykjavik

你可能感兴趣的:(gcc 编译错误,和架设web注意点)