专注于高品质PHP技术等信息服务于一体 [STIEMAP] [RSS]

百度提供的广告:
Linux
当前位置:首页 > 技术文档 > Linux >  > 
ubuntu 11 安装 nginx mysql php
1,php 5.3.10
#./configure --prefix=/usr/local/php5  --with-gd  --enable-fpm  --with-jpeg-dir  --with-png-dir  --enable-mbstring
错误 configure: error: xml2-config not found. Please check your libxml2 installation.
安装这个包
# apt-get install libxml2
在编译错误
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
禁用这个好了
--disable-libxml
在编译又是错误
configure: error: DOM extension requires LIBXML extension, add --enable-libxml
apt-get install libxml2-dev
在编译又是错误
configure: error: jpeglib.h not found.
apt-get install jpeg62*
在编译又是错误
configure: error: png.h not found.
apt-get install libpng-dev
在编译
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
成功了。
#make && make install
经过漫长时间的等待
#cp php.ini-development /usr/local/php5/lib/php.ini 复制 php.ini
#cp /usr/local/php5/etc/php-fpm.conf.default php-fpm.conf 复制 fpm 配置文件
#/usr/local/php5/bin/php -varsoin
PHP 5.3.10 (cli) (built: Apr  8 2012 14:47:37)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
#/usr/local/php5/sbin/php-fpm 启动 php fpm
错误
[08-Apr-2012 14:57:53] ERROR: [pool www] cannot get gid for group 'nobody'
[08-Apr-2012 14:57:53] ERROR: FPM initialization failed
添加 nobody 组 和 nobody 用户
#groupadd nobody
#useradd nobody
在启动php fpm
#/usr/local/php5/sbin/php-fpm
没有报错,查看一下进程
#ps -aux | grep php
root      7797  0.0  0.4  18304  2148 ?        Ss   15:03   0:00 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)
PHP 安装成功 因为还没有装 mysql 这次没有编译 mysql
2,nginx 安装
#./configure --prefix=/usr/local/nginx
编译有错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
安装 pcre
#apt-get install libpcre3-dev

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
编译成功 可以安装
#make && make install  
启动 nginx
#/usr/local/nginx/sbin/nginx
打开浏览器 http://localhost
Welcome to nginx! 安装成功
nginx 支持 php
#vi /usr/local/nginx/conf/nginx.conf
把以下取消注释
 location ~ \.php$ {
    root     html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
    include        fastcgi_params;
}
重启 nginx
#pkill -9 nginx
#/usr/local/nginx/sbin/nginx
写 phpinfo 测试
PHP Version 5.3.10
成功
System     Linux waphack-virtual-machine 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011 i686
Build Date     Apr 8 2012 14:45:37
Configure Command     './configure' '--prefix=/usr/local/php5' '--with-gd' '--enable-fpm' '--with-jpeg-dir' '--with-png-dir' '--enable-mbstring'
Server API     FPM/FastCGI
Virtual Directory Support     disabled
Configuration File (php.ini) Path     /usr/local/php5/lib
Loaded Configuration File     /usr/local/php5/lib/php.ini
mysql 安装
# /usr/local/mysql/scripts/mysql_install_db --user=mysql
错误
FATAL ERROR: Could not find mysqld

The following directories were searched:

    /usr/libexec
    /usr/sbin
    /usr/bin

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
加上mysql 安装目录 utuntu 有这个问题 red hat 5 没有发现
#/usr/local/mysql# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h waphack-virtual-machine password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!
#cp support-files/mysql.server /etc/init.d/mysql.server
#cp support-files/my-medium.cnf /etc/my.cnf
#/usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking  &
启动安全模式报错 查看错误日志
120408 21:09:32 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120408 21:09:32 [ERROR] Can't find messagefile '/usr/share/english/errmsg.sys'
120408 21:09:32 [Note] Plugin 'FEDERATED' is disabled.
120408 21:09:32  InnoDB: Initializing buffer pool, size = 8.0M
120408 21:09:32  InnoDB: Completed initialization of buffer pool
120408 21:09:33  InnoDB: Started; log sequence number 0 44233
bin/mysqld: Too many arguments (first extra is 'start').
Use --verbose --help to get a list of available options
120408 21:09:33 [ERROR] Aborting

120408 21:09:33  InnoDB: Starting shutdown...
120408 21:09:38  InnoDB: Shutdown completed; log sequence number 0 44233
120408 21:09:38 [Note]
在 my.cnf 中添加以下
[mysqld]
language = /usr/local/mysql/share/english
在次启动还是有错误
120408 21:32:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120408 21:32:28 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120408 21:32:28 [Note] Plugin 'FEDERATED' is disabled.
120408 21:32:28  InnoDB: Initializing buffer pool, size = 8.0M
120408 21:32:28  InnoDB: Completed initialization of buffer pool
120408 21:32:28  InnoDB: Started; log sequence number 0 44233
120408 21:32:28 [ERROR] Can't start server : Bind on unix socket: Permission denied
120408 21:32:28 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
120408 21:32:28 [ERROR] Aborting

120408 21:32:28  InnoDB: Starting shutdown...
120408 21:32:33  InnoDB: Shutdown completed; log sequence number 0 44233
120408 21:32:33 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

120408 21:32:33 mysqld_safe mysqld from pid file /var/lib/mysql/waphack-virtual-machine.pid ended

#reboot 重启一下linux
#/usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking  &
#ps aux | grep mysql 可以看到mysql 进程了
/* sql
update mysql.user set password=PASSWORD('123') where User='root';
flush privileges;
*/
强制结束进程
ps 查出进程ID  kill 杀掉
#/usr/local/mysql/bin/mysqld start
还是有错误,在重启一下
#reboot
#/usr/local/mysql/bin/mysqld start
还是有错误
120408 22:00:22 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120408 22:00:22 [Note] Plugin 'FEDERATED' is disabled.
120408 22:00:22  InnoDB: Initializing buffer pool, size = 8.0M
120408 22:00:22  InnoDB: Completed initialization of buffer pool
120408 22:00:22  InnoDB: Started; log sequence number 0 44233
120408 22:00:22 [Note] Recovering after a crash using mysql-bin
120408 22:00:22 [Note] Starting crash recovery...
120408 22:00:22 [Note] Crash recovery finished.
120408 22:00:22 [ERROR] Can't start server : Bind on unix socket: No such file or directory
120408 22:00:22 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
120408 22:00:22 [ERROR] Aborting

120408 22:00:22  InnoDB: Starting shutdown...
120408 22:00:27  InnoDB: Shutdown completed; log sequence number 0 44233
120408 22:00:27 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
明天在弄吧。