手动阀

Good Luck To You!

Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17详细配置

在CentOS上搭建PHP 5.3.8、Nginx 1.0.9和MySQL 5.5.17的详细配置步骤如下:

更新系统

确保你的系统是最新的。

sudo yum update y

安装必要的依赖包

sudo yum install y gcc gccc++ make zlibdevel openssldevel curldevel libxml2devel bzip2devel

安装MySQL 5.5.17

下载并安装MySQL

cd /usr/local/src
wget http://downloads.mysql.com/archives/get/p/23/file/mysql5.5.17.tar.gz
tar zxvf mysql5.5.17.tar.gz
cd mysql5.5.17
cmake .
make
sudo make install

初始化数据库

sudo scripts/mysql_install_db user=mysql basedir=/usr/local/mysql datadir=/usr/local/mysql/data

配置MySQL

编辑/etc/my.cnf文件,添加以下内容:

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
user = mysql
symboliclinks = 0
[mysqld_safe]
logerror = /var/log/mysqld.log
pidfile = /var/run/mysqld/mysqld.pid

启动MySQL服务

sudo cp supportfiles/mysql.server /etc/init.d/mysql
sudo service mysql start

设置root密码

/usr/local/mysql/bin/mysqladmin u root password 'yourpassword'

安装PHP 5.3.8

下载并安装PHP

cd /usr/local/src
wget http://museum.php.net/php5/php5.3.8.tar.gz
tar zxvf php5.3.8.tar.gz
cd php5.3.8
./configure prefix=/usr/local/php withconfigfilepath=/usr/local/php enablembstring withmysql=/usr/local/mysql withopenssl withzlib withcurl enablefpm
make
sudo make install

配置PHP

编辑/usr/local/php/etc/php.ini文件,根据需要修改配置,启用常用扩展:

extension=mysql.so
extension=mysqli.so
extension=pdo_mysql.so

安装Nginx 1.0.9

下载并安装Nginx

cd /usr/local/src
wget http://nginx.org/download/nginx1.0.9.tar.gz
tar zxvf nginx1.0.9.tar.gz
cd nginx1.0.9
./configure prefix=/usr/local/nginx withhttp_ssl_module withpcre withhttp_fastcgi_module withhttp_gzip_static_module
make
sudo make install

配置Nginx

编辑/usr/local/nginx/conf/nginx.conf文件,添加以下内容:

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octetstream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

启动Nginx服务

sudo /usr/local/nginx/sbin/nginx

配置PHPFPM

编辑/usr/local/php/etc/phpfpm.conf文件,添加以下内容:

[www]
listen = 127.0.0.1:9000
user = nobody
group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
chdir = /

启动PHPFPM服务:

sudo /usr/local/php/sbin/phpfpm

测试安装

创建一个PHP测试文件来验证安装是否成功。

echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php

访问http://your_server_ip,你应该能看到PHP信息页面。

步骤涵盖了在CentOS上安装和配置PHP 5.3.8、Nginx 1.0.9和MySQL 5.5.17的基本过程,请根据你的具体需求进行进一步的配置和优化。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-BlogPHP 1.7.3

Copyright Your WebSite.Some Rights Reserved.