1. 先安装nginx,没有特殊的配置地方。
2. 再安装解压mysql。没有需要特殊配置的地方
3. php编译安装,需要很多参数,以及指定mysql的安装目录。
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype
4. php配置文件
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/src/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
#拷贝php-fpm到启动目录
chmod +x /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
5. nginx ,fpm 都配置www用户,用户组需要一致
6.配置iptables
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart
7.修改nginx配置文件,取消默认php的location中的注释
不过要加上
include fastcgi.conf;
8. test script
-
<?php
-
#phpinfo();
-
$dsn = 'mysql:dbname=test;host=localhost'; //mysql
-
$user = 'root'; //mysql
-
$password = '87573096'; //mysql
-
$db = new PDO($dsn, $user, $password); //mysql
-
#$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
$sql = 'INSERT INTO `user` (`id`, `name`, `sex`) VALUES (\'2\',\'lucy\',\'female\');'; //mysql
-
$stmt = $db->query($sql); //这以下mysql和pgsql是一样的了
-
#$stmt->setFetchMode(PDO::FETCH_ASSOC);
-
#$r = $stmt->fetchAll();
-
?>
阅读(841) | 评论(0) | 转发(0) |