Ubuntu11.10_X86_32,编译安装相应的软件:nginx+mysql+php。
libiconv-1.14.tar.gz
libmcrypt-2.5.7.tar.gz
mcrypt-2.6.8.gz
mhash-0.9.9.9.tar.gz
mysql-5.5.39.tar.gz
nginx-1.1.10.tar.gz
pcre-8.20.tar.gz
php-5.4.34.tar.gz
系统较为纯净要安装一些必要的工具软件
apt-get install gcc g++ ssh automake cmake build-essential autoconf make re2c wget cron bzip2 rcconf flex vim bison m4 mawk cpp binutils libncurses5 unzip tar libncurses5 libncurses5-dev libtool libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev libltdl3-dev libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev libltdl3-dev libmcrypt-dev
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
cd libiconv-1.14/
./configure --prefix=/usr/local
make
make install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install
groupadd mysql #添加mysql组
useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
mkdir -p /data/mysql #创建MySQL数据库存放目录
chown -R mysql:mysql /data/mysql #设置MySQL数据库目录权限
tar zxvf mysql-5.5.19.tar.gz
cd mysql-5.5.19
mkdir -p /usr/local/mysql #创建MySQL安装目录
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8-unicode_ci -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306
make
make install
cp support-files/my-small.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
/usr/local/mysql/scripts/mysql_install_db --user=mysql
cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:/etc目录下面默认有一个my.cnf,直接覆盖即可)
vi /etc/my.cnf #编辑配置文件,在 [mysqld] 部分增加
datadir = /data/mysql #添加MySQL数据库路径
./scripts/mysql_install_db --user=mysql #生成mysql系统数据库
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
chmod 755 /etc/init.d/mysqld #增加执行权限
启动:bin/mysqld_safe -user=mysql &
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
修改密码/usr/local/mysql/bin/mysqladmin -u root -p password "123456"
错误1:
解决办法:
apt-get install libfreetype6-dev libjpeg8-dev libpng12-dev slapd ldap-utils db5.1-util
apt-get install libldap2-dev libsasl2-dev
./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-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --disable-maintainer-zts
错误1:configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
解决方法:apt-get install curl
apt-get install libcurl4-gnutls-dev
apt-get install php5-curl
错误2:找不到ldap
解决方法:在配置信息中删除 ----with-ldap
make ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp php.ini-production /usr/local/php/etc/php.ini
执行命令查看PHP相关配置,获取PHP扩展存放目录extension-dir值:/usr/local/php/bin/php-config
这里显示extension_dir =的信息 // http://www.pprar.com
vi /usr/local/php/etc/php.ini
修改:extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
创建fastcgi配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
修改fastcgi配置文件
vi /usr/local/php/etc/php-fpm.conf
去掉注释以下几行的注释
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers
修改文件以下两行,不修改启动fastcgi会报错 “fastcgi [pool www] cannot get gid for group ‘nobody’”
user = nobody
group = nobody
修改为
user = www
group = www
错误1:“fastcgi [pool www] cannot get gid for group ‘www’”
解决方法:需要自己创建用户以及组
Sudo useradd www
启动fastcgi
/usr/local/php/sbin/php-fpm
错误2:ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
ERROR: FPM initialization failed
解决方法:netstat -lntup | grep 9000
killall php-fpm
错误3:couldn't load module: /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: cannot open shared object file: No such file or directory
解决方法:1)安装 getlibs
下载:getlibs-all.deb
执行:sudo dpkg -i --force-all getlibs-all.deb
sudo apt-get update getlibs aapt
2)安装32位库
getlibs -p gnome-keyring:i386
3)生成符号链接
sudo ln -s /usr/lib32/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so
tar zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module
make
make install
启动Nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
重启服务:/usr/local/nginx/sbin/nginx
停止服务:killall nginx
vi /usr/local/nginx/conf/nginx.conf
添加
server {
listen 7070; #外网访问端口号
server_name blue-desk.com.cn;
location / {
root /usr/local/src/wwwroot; #应用所在地址
index index.html index.htmi index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /usr/local/src/wwwroot; #应用所在地址
fastcgi_pass 10.128.7.101:9000; #与php-fpm联系的端口号,php-fpm的配置在/usr/local/php/etc/php-fpm.conf
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/src/wwwroot$fastcgi_script_name; #/usr/local/src/wwwroot 应用所在地址
include fastcgi_params;
}
}
onethink 应用配置
数据库名:mysql
用户名: root
数据库密码:123456