CentOS 6 编译安装Nginx+PHP+Mysql,有需要的朋友不妨参考下。
[1].安装Nginx
复制代码代码如下:
# useradd www -M -s /sbin/nologin
复制代码代码如下:
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip
# unzip pcre-8.13.zip # cd pcre-8.13 # ./configure # make && make install
复制代码代码如下:
# 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
复制代码代码如下:
# yum -y install libjpeg-devel libpng-devel
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz # tar -zxvf libmcrypt-2.5.7.tar.gz # cd libmcrypt-2.5.7 # ./configure # make && make install
复制代码代码如下:
# ln -s /usr/lib64/mysql/ /usr/lib/mysql
==64位系统==
复制代码代码如下:
# 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
复制代码代码如下:
# 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]
safe_mode = On register_globals = Off magic_quotes_gpc = Off allow_url_fopen = Off allow_url_include = Off expose_php=Off disable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var [Date] date.timezone = “Asia/Shanghai”
复制代码代码如下:
[global]
pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice emergency_restart_threshold = 0 emergency_restart_interval = 0 [www] pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500
复制代码代码如下:
# 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
复制代码代码如下:
# mkdir -p /usr/local/mysql/
复制代码代码如下:
# mkdir -p /data/mysql/
复制代码代码如下:
# useradd mysql -M -s /sbin/nologin
# chown mysql.mysql -R /data/mysql/
复制代码代码如下:
# yum -y install cmake
# yum -y install ncurses-devel
复制代码代码如下:
-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
复制代码代码如下:
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
复制代码代码如下:
# 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
复制代码代码如下:
# /etc/init.d/mysql start
# mysqladmin -uroot password '123123'
复制代码代码如下:
1: UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新设置密码)
(责任编辑:IT)2: flush privileges;(刷新权限) |