onlyfu's Blog

gcc编译时加头文件参数与位置,学习《UNIX环境高级编程》

gcc ls1.c -I ../include/

../include为头文件所在位置

如:

#include "error.c"  //此文件在../include/中
#include <dirent.h>

int
main(int argc, char *argv[])
{
        DIR                             *dp;
        struct dirent   *dirp;

        if (argc != 2)
                err_quit("usage: ls directory_name");

        if ((dp = opendir(argv[1])) == NULL)
                err_sys("can't open %s", argv[1]);
        while ((dirp = readdir(dp)) != NULL)
                printf("%s\n", dirp->d_name);

        closedir(dp);
        exit(0);
}

linux apache开启伪静态

1、进入apache源文件目录
2、找到mod_rewrite.c的位置,用find . -name mod_rewrite.c
3、进入到mod_rewrite.c所在的目录
4、编译/usr/local/apache2/bin/apxs -c mod_rewrite.c  ///usr/local/apache2/bin/apxs为你已安装apahce的位置
5、找到前面编译生成的mod_rewrite.so的位置,用find . -name mod_rewrite.so
6、将mod_rewrite.so复制到apache目录中的modules目录下
7、修改httpd.conf,将LoadModule rewrite_module  modules/mod_rewrite.so加上
8、将<Directory "/usr/local/apache2/htdocs">下面的AllowOverride None改为AllowOverride All
9、重启apache
10、将rewrite规则文件.htaccess写好,放到WEB根目录下,注意RewriteBase的设置,根目录就用/,子目录用/dir

ubuntu apache开启rewrite

1、在终端输入 sudo a2enmod rewrite 开启 Mod_rewrite 模块;

2、在终端输入 sudo gedit /etc/apache2/sites-enabled/000-default 找到相应的目录将 AllowOverride none 改为 AllowOverride All;

3、重启apache2 :sudo /etc/init.d/apache2 restart;

Ubuntu下安装Apache+Mysql+php

1、安装Apache服务
sudo apt-get install apache2


2、安装php5
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart


3、安装mysql
sudo apt-get install mysql-server
安装完成按提示设置root密


4、让apache、php支持mysql
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart

Linux下设置apache开机启动

测试环境:
1、apache 2.2.9,安装在/usr/local/apahce2下
2、red hat enterprise linux 5
第一步:
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd //如果有其他的版本的Apache存在,也可以直接覆盖掉
第二步:
使用编辑器打开httpd文件,并在第一行#!/bin/sh下增加两行文字如下
# chkconfig: 35 70 30
# description: Apache
接着注册该服务
chkconfig –add httpd
一切OK了,启动服务
service httpd start
其中所增加的第二行中三个数字第一个表示在运行级别3和5下启动apache,第二、三是关于启动和停止的优先级配置,无关紧要。