专栏首页python3Linux + Apache + Mys

Linux + Apache + Mys

 一、下载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

MOD_WSGI:  http://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2

PYTHON2.7:  http://python.org/download/

#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*

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • mysql系列之多实例3----基于my

        上一篇博文mysql系列之多实例2----基于多配置文件介绍了,如何部署基于多配置文件的mysql多实例,本篇博文将介绍基于mysql自带的mysqld...

    py3study
  • mysql_python

    安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos...

    py3study
  • mysql 3.x拿webshell

    mysql> Create TABLE demo (sanr text NOT NULL);

    py3study
  • java架构之路(Sharding JDBC)mysql5.7yum安装和主从

    每个人都不一样,别复制我的。输入mysql -uroot -p,然后输入你的密码进入

    小菜的不能再菜
  • 搭建 LNMP 环境

    LNMP是建立web应用的平台,是Linux、NGINX,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的简称...

    剧终
  • mysqld_multi方式配置Mysql数据库主从复制

    mysqld_multi设计用于管理在同一台机器上运行的多个mysqld进程,这些进程使用不同的socket文件并监听在不同的端口上。mysqld_multi可...

    Java帮帮
  • centos安装mysql-server报错:No package mysql-server available.

    下面再执行安装命令 yum install mysql-server -y,是不是就可以了呢,嘿嘿>>>

    bboy枫亭
  • Ubuntu安装配置MySQL

    注:建议将/etc/apt/source.list中的cn改成us,美国的服务器比中国的快很多,修改命令如下:sudo sed -i "s/cn/us/g" s...

    阳光岛主
  • [docker]安装Mysql

    贰叁壹小窝
  • docker安装mysql及navicat远程连接

    华创信息技术

扫码关注云+社区

领取腾讯云代金券