Lamp管理












Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)")

改为/mysqld.sock



client denied by server configuration 

<Directory />

AllowOverride all

Require all granted

</Directory>




一、环境,python2.5.4:

    1、linux环境:Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

    2、apache2.2.6

    3、Django-1.2-rc-1

    4、mod_wsgi-3.2

二、安装django

    python setup.py install

三、Apache2.2.6安装:

    ./configure --prefix=/usr/local/apache2--enable-mods-shared=most--enable-rewrite--enable-forward--with-mpm=worker

    make

    make install

四、安装mod_wsgi:

   ./configure--with-apxs=/usr/local/apache2/bin/apxs--with-python=/usr/bin/python

    make

    make install

五、配置

   我的应用在/mnt/www/下,名称叫mysite,在mysite中创建apache与media目录,然后如下操作:

    1、创建apache_django_wsgi.conf文件,内容如下:

Alias /site_media/ /mnt/www/mysite/media/

<Directory /mnt/www/mysite/media>

    Order allow,deny

    Options Indexes

    Allow from all

    IndexOptions FancyIndexing

</Directory>

 

Alias /media/ /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/

<Directory /usr/local/lib/python2.5/site-packages/django/contrib/admin/media>

    Order allow,deny

    Options Indexes

    Allow from all

    IndexOptions FancyIndexing

</Directory>

WSGIScriptAlias / /mnt/www/mysite/apache/django.wsgi

<Directory /mnt/www/mysite>
    Order deny,allow 
    Allow from all
</Directory>

<Directory /mnt/www/mysite/apache>

    Allow from all

</Directory>

    2、创建django.wsgi文件,内容如下:

import os, sys


#Calculate the path based on the location of the WSGI script.

apache_configuration= os.path.dirname(__file__)

project = os.path.dirname(apache_configuration)

workspace = os.path.dirname(project)

sys.path.append(workspace)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

os.environ['PYTHON_EGG_CACHE'] = '/tmp'

#上一句能解决Exception occurred processing WSGI script的问题

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

print >> sys.stderr, sys.path

    3、设置apache的httpd.conf文件:

        加入LoadModule wsgi_module modules/mod_wsgi.so

         加入Include /mnt/www/mysite/apache/apache_django_wsgi.conf

六、效果:

   执行:/usr/local/apache2/bin/apachectl start,访问http://机器IP,显示如下:










如何启动/停止/重启MySQL

一、启动方式

1、使用 service 启动:service mysqld start

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

3、使用 safe_mysqld 启动:safe_mysqld&

二、停止

1、使用 service 启动:service mysqld stop

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop

3、mysqladmin shutdown

三、重启

1、使用 service 启动:service mysqld restart

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart
提问 编辑摘要


如何启动/停止/重启MySQL
一、启动方式

1、使用 service 启动:service mysqld start

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

3、使用 safe_mysqld 启动:safe_mysqld&

二、停止

1、使用 service 启动:service mysqld stop

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld stop

3、mysqladmin shutdown

三、重启

1、使用 service 启动:service mysqld restart

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart

刚开始学mysql时都是用redhat自带的。启动是什么 /rc.d/init.d/ start
这很简单,但是后来越学越多,系统自带的mysql,有的是版本太低,有的是与
自己想要装的web服务需要的低版本的mysql


后来自己学着以tar的方式安装mysql,我的mysql装在/usr/local/mysql目录下启


动碰到过很多问题。最常见的是:
ERROR 2002: Can't connect to local MySQL server through socket


'/tmp/mysql.sock' (111)


解决办法:
[root@test mysql]# /usr/local/mysql/bin/mysqladmin -u root /
> -S /var/lib/mysql/mysql.sock password 'your.passwd'
或者做个连接
ln -s /var/lib/mysql/mysql.sock /tmp
其实提示找不到 /tmp/mysql.sock有时也并不是/tmp目录下没这个文件,是启动
命令不对,我碰到过
常见的几种启动方式,自己也不是记得很清楚,如果你确定tmp下有mysql.sock这
个文件不妨试试另外的几个命令
/usr/local/mysql/bin/mysql -u root -p
/usr/local/mysql/bin/mysqld --user=mysql&
/usr/local/mysql/bin/mysqld --user=root&
/usr/local/mysql/bin/mysqld_safe --user=root&
/usr/local/mysql/bin/mysqld_safe --user=mysql&
/usr/local/mysql/bin/safe_mysqld--uer=root&(注意safe_mysqld与mysqld_safe是不同的,&表示mysql在后台运行)我的就会报错了
STOPPING server from pid file
/usr/local/mysql/data/localhost.localdomain.pid
060304 11:46:21 mysqld ended
这是权限问题,我的mysql目录属于root用户,也属于root群组,改用mysqld_safe启动就没问题了,
大家只要注意这几个mysql,safe_mysqld,mysqld_safe,mysqld,mysqladmin.多试
几次
其实有时mysql已经正常启动了,查看mysql是否启动命令
ps -aux | grep mysqld
会看到如下类似内容
mysql 6394 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
mysql 6395 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
mysql 6396 0.0 1.5 10528 992 pts/3 S 16:16 0:00
/usr/local/mysql/
root 6422 0.0 1.1 2408 732 pts/3 S 16:20 0:00 grep
mysql


查看mysql是否在监听端口命令
netstat -tl | grep mysql
会看到如下类似内容
tcp 0 0 *:mysql *:* LISTEN



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值