Linux + Apache + Mys

发布时间:2019-08-12 11:50:48编辑:auto阅读(1721)

     一、下载apache  apr  apr-util   pcre

             APACHE:     http://www.fayea.com/apache-mirror/httpd/

                     APR:     http://www.fayea.com/apache-mirror/apr/

            APR-UTIL:   http://www.fayea.com/apache-mirror/apr/

                    PCRE:   ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

       #mkdir  /usr/local/lamp

       # cd apr-1.4.6

       # ./configure --prefix=/usr/local/lamp/apr
       # cd apr-util-1.5.1
       # ./configure --prefix=/usr/local/lamp/apr-util  --with-apr=/usr/local/lamp/apr
       # cd pcre-8.32
       # ./configure --prefix=/usr/local/lamp/pcre
       # cd  httpd-2.4.3
       # ./configure --prefix=/usr/local/lamp/apache2 --with-apr=/usr/local/lamp/apr --with-apr-util=/usr/local/lamp/apr-util --with-pcre=/usr/local/lamp/pcre
      配置虚拟主机:
      将/usr/local/lamp/apache2/conf/httpd.conf 中的Include conf/extra/httpd-vhosts.conf注释去掉
            将ServerName 改为 ServerName localhost.com:80
            # vi /etc/hosts         加入127.0.0.1 localhost.com
            # vi  /usr/local/lamp/apache2/conf/extra/httpd-vhosts.conf 
           注释掉这些自带的虚拟机
    #<VirtualHost *:80>
    #    ServerAdmin webmaster@dummy-host.example.com
    #    DocumentRoot "/usr/local/lamp/apache2/docs/dummy-host.example.com"
    #    ServerName dummy-host.example.com
    #    ServerAlias www.dummy-host.example.com
    #    ErrorLog "logs/dummy-host.example.com-error_log"
    #    CustomLog "logs/dummy-host.example.com-access_log" common
    #</VirtualHost>
    #
    #<VirtualHost *:80>
    #    ServerAdmin webmaster@dummy-host2.example.com
    #    DocumentRoot "/usr/local/lamp/apache2/docs/dummy-host2.example.com"
    #    ServerName dummy-host2.example.com
    #    ErrorLog "logs/dummy-host2.example.com-error_log"
    #    CustomLog "logs/dummy-host2.example.com-access_log" common
    #</VirtualHost>
    配置我们自已的:
    <VirtualHost *:80>
        ServerAdmin webmaster@dummy-host2.example.com
        DocumentRoot "/home/you/www/django"
        ServerName  django.com
        ErrorLog "/home/han/www/django/errorLog.txt"
        CustomLog "logs/dummy-host2.example.com-access_log" common
    </VirtualHost>
    配置httpd.conf使虚拟目录有访问权限:
    <Directory "/home/you/www/django">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
     在you(你的家目录)下建立目录www/django
     在django目录下建index.html 文档写入 “工作了"三个字
    # /usr/local/lamp/apache2/bin/apachectl start
    打开浏览器输入地址django.com
    看到 ”工作了" 三字就成功了
     
     
     
    配置启用CGI
    #LoadModule cgid_module modules/mod_cgid.so取消注释
     ScriptAlias /cgi-bin/ "/usr/local/lamp/apache2/cgi-bin/"
    <Directory "/usr/local/lamp/apache2/cgi-bin">
        AllowOverride None
        #Options None
        Options ExecCGI
        Require all granted
    </Directory>
      AddHandler cgi-script .cgi
    在cgi-bin目录下写test.cgi粘贴如下内容,并且保证test.cgi有执行权限
    #!/usr/bin/python
    # -*- coding:UTF-8 -*-
    print "Content-type: text/html\n"
    print "<html><head>世界,你好!</head></html>
    在浏览器输入127.0.0.1/cgi-bin/test.cgi看看效果
     
     
     
     
     
     
     
     
    安装PYTHON 和mod_wsgi
     
     
    #cd Python-2.7.3/
    #./configure --prefix=/usr/local/lamp/python
    #make & make install
    # cd mod_wsgi-3.4/
    [root@fedora mod_wsgi-3.4]# ./configure --with-apxs=/usr/local/lamp/apache2/bin/apxs --with-python=/usr/local/lamp/python/bin/python
    [root@fedora mod_wsgi-3.4]# make & make install
    配置apache使通过mod_wsgi连接能够解析python
    # vi /usr/local/lamp/apache2/conf/httpd.conf 
    加入LoadModule wsgi_module modules/mod_wsgi.so
    WSGIScriptAlias / "/home/you/www/mysite/apache/django.wsgi"
    WSGIPythonPath /home/han/www/mysite
    在django.wsgi中写入:
     import os, sys
    sys.path.append('/home/you/www/mysite')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
     
     
     安装MYSQL
    ./mysqld: Table 'mysql.plugin' doesn't exist
    130107 15:46:43 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
     
    FATAL ERROR: Could not find ./bin/my_print_defaults
     
     
     
     cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/lamp/mysql -DMYSQL_DATADIR=/home/han/www/mysql/data -DMYSQL_UNIX_ADDR=/var/tmp/mysql/mysqld.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_SPHINX_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1  -DMYSQL_USER=mysql
     #chgrp -R mysql .
     
     #scripts/mysql_install_db --user=mysql
    #chown -R mysql data
    # cp support-files/my-medium.cnf /etc/my.cnf
    #bin/mysqld_safe --user=mysql
    #cp support-files/mysql.server /etc/init.d/mysqld

    #cd /usr/local/bin

     

    [root@fedora bin]# ln -fs /usr/local/lamp/mysql/bin/mysql mysql

    把mysql 添加到系统服务启动

     

    [root@fedora init.d]# cp /usr/local/lamp/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld 

    cd /etc/rc.d/init.d

    chkconfig --add mysqld

     

    5 修改启动脚本

    vi /etc/init.d/mysqld

     

    6. 启动和停止mysql

    service mysqld start/stop

    7.设置mysql的root密码

    /usr/local/lamp/mysql/bin/mysqladmin -uroot -p passwd 'mysqlmima'

    到此mysql-5.5.16 就安装完毕。记录下希望对大家有帮助。

     

    问题:

     

    [root@fedora scripts]# /etc/rc.d/init.d/mysqld status

    MySQL is running but PID file could not be found           [FAILED]

    [root@fedora scripts]# service mysqld start

    Starting MySQL.The server quit without updating PID file (/home/han/www/mysql/data/fedora.pid).       [FAILED]

    原来没有对表进行初始化
    #cd /usr/local/lamp/mysql
    #chown -R mysql .   (最后空不格有一个点)
    [root@fedora mysql]# su mysql
    [mysql@fedora mysql]$ scripts/mysql_install_db
    [mysql@fedora mysql]$ /usr/local/lamp/mysql/bin/mysqld_safe --user=mysql &
    FATAL ERROR: Could not find ./bin/my_print_defaults
    回到上scripts的上一级目录就没这问题了
     
    MySQL server PID file could not be found![FAILED]
    #ps aux|grep mysq*
     

    Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

    [mysql@fedora mysql]$ ./scripts/mysql_install_db 

     

    [mysql@fedora mysql]$ ./bin/mysqld_safe --user=mysql &

    [mysql@fedora mysql]$ ./bin/mysql_upgrade 
    [mysql@fedora mysql]$ ./scripts/mysql_install_db --ldata=/home/han/www/mysql/data
     

     

     unsupported storage engine: InnoDB

     

    原因:MySQL5.5.8 GA默认引擎为InnoDB,而配置文件(my.cnf)中设置了skip-innodb
    解决:在配置文件(my.cnf)中设置default-storage-engine=MyISAM

     ./mysql-bin.index' not found (Errcode: 13)

    原来mysql-bin.index没有写权限  chmod 666 mysql-bin.index

    mysqld: Table ‘mysql.plugin’ doesn’t exist

    mysql$ mysqld –skip-grant &

    ./bin/mysql_upgrade -d /home/you/www/mysql/data 

      Table 'mysql.plugin' doesn't exist

    130107 21:20:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

     

     在httpd.conf中加入  MaxRequestsPerChild 1  再修改DJANGO代码不用重启apache

     

    安装mysql for python : http://sourceforge.net/projects/mysql-python/

     

     cannot find -lprobes_mysql 增加 -DENABLE_DTRACE=OFF 编译选项

    在mysql_config中libs=" $ldflags -L$pkglibdir -lmysqlclient   -lpthread -lprobes_mysql -lz -lm -lrt -ldl "
    这一行中删除掉 -lprobes_mysql
    libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r   -lpthread -lprobes_mysql -lz -lm -lrt -ldl   "这一行也删除-lprobes_mysql
     

    解决libmysqlclient.so.18: cannot open shared object file: no such file or directory failed问题  

     

     ln -s /usr/local/lamp/mysql/lib/libmysqlclient.so.18 /usr/lib/

    再重新安装mysql-python
     

     安装postgresql      PyGreSQL

    Exception: pg_config tool is not available.

    把os.popen('pg_config --%s' % s)   改为os.popen('/usr/local/lamp/pgsql/bin/pg_config --%s' % s)

     

    ImportError: libpq.so.5: cannot open shared object file: No such file or directory

    解决:

    cd /etc/ld.so.conf.d
    echo "/usr/local/pgsql/lib" >>pgsql.conf
    ldconfig

    问题No module named psycopg2.extensions

    解决[root@fedora mysite]# yum install python-psycopg2*

     

     

     

     

关键字

上一篇: python 实现socket

下一篇: python安装过程