CentOS 6 编译安装Nginx+PHP+Mysql
[1].安装 Nginx
1,添加一个不能登录且没有主目录的用户:
|
1
|
# useradd www -M -s /sbin/nologin |
2,必要的组件
|
1
2
3
4
5
|
# unzip pcre-8.13.zip# cd pcre-8.13# ./configure# make && make install |
3,编译nginx并安装
|
1
2
3
4
|
# tar -zxvf nginx-1.1.2.tar.gz# cd nginx-1.1.2# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module# make && make install |
[2].安装 PHP
1,安装必要的组件
|
1
2
3
4
5
6
|
# yum -y install libjpeg-devel libpng-devel# tar -zxvf libmcrypt-2.5.7.tar.gz# cd libmcrypt-2.5.7# ./configure# make && make install |
==64位系统==
|
1
|
# ln -s /usr/lib64/mysql/ /usr/lib/mysql |
==64位系统==
2,编译php并安装
|
1
2
3
|
# cd php-5.3.8# ./configure --prefix=/usr/local/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www# make && make install |
3,拷贝和修改php配置文件
|
1
2
3
|
# cp php.ini-production /usr/local/php/lib/php.ini 或是 /usr/local/lib/php.ini# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf# /usr/local/php/bin/php --ini //测试ini文件是否加载 |
修改php.ini
|
1
2
3
4
5
6
7
8
9
10
|
[PHP]safe_mode = Onregister_globals = Offmagic_quotes_gpc = Offallow_url_fopen = Offallow_url_include = Offexpose_php=Offdisable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var[Date]date.timezone = “Asia/Shanghai” |
修改php-fpm.conf
|
1
2
3
4
5
6
7
8
9
10
11
|
[global]pid = run/php-fpm.piderror_log = log/php-fpm.loglog_level = noticeemergency_restart_threshold = 0emergency_restart_interval = 0[www]pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500 |
4,添加服务启动脚本
|
1
2
3
4
5
6
7
8
|
# cp nginx /etc/init.d/nginx# cp php-fpm /etc/init.d/php-fpm# chmod 755 /etc/init.d/nginx# chmod 755 /etc/init.d/php-fpm# chkconfig --add nginx# chkconfig --add php-fpm# chkconfig nginx on# chkconfig php-fpm on |
[3].安装 Mysql
3.1, 创建mysql安装目录
|
1
|
# mkdir -p /usr/local/mysql/ |
3.2, 创建数据存放目录
|
1
|
# mkdir -p /data/mysql/ |
3.3, 创建用户和用户组与赋予数据存放目录权限
|
1
2
|
# useradd mysql -M -s /sbin/nologin# chown mysql.mysql -R /data/mysql/ |
3.4, 安装必要的组件
|
1
2
|
# yum -y install cmake# yum -y install ncurses-devel |
3.5, 编译安装Mysql
|
1
2
|
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306# make && make install |
3.6, 初始化数据库
|
1
2
|
# cd /usr/local/mysql# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/ |
3.7, 配置环境
|
1
2
3
4
5
|
# cp support-files/my-medium.cnf /etc/my.cnf# cp support-files/mysql.server /etc/init.d/mysql# chmod 755 /etc/init.d/mysql# chkconfig mysql on# export PATH=/usr/local/mysql/bin:$PATH |
3.8, 启动并设置初始密码
|
1
2
|
# /etc/init.d/mysql start# mysqladmin -uroot password '123123' |
进行再修改密码的语句
1: UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新设置密码)
2: flush privileges;(刷新权限)
姓名:Chinadu
近期评论