标签:nmp connect 反向 php.ini bst web /etc eve utf8
LNMP是目前应用最为广泛的网站服务器架构,Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统。代表版本有:debian、centos、ubuntu、fedora、gentoo等,Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器,Mysql是一个小型关系型数据库管理系统,PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
useradd -M -s /sbin/nologin nginx
tar xzvf nginx-1.6.0.tar.gz -C /opt
cd /opt/nginx-1.6.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module #开启stub_status状态统计模块
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
########### nginx管理命令 ###########
nginx -t #nginx配置文件检查
nginx #启动
killall -1 nginx #重启nginx
killall -3 nginx #停止nginx
######################################
vi /etc/init.d/nginx
#!/bin/bash
#chkconfig: - 99 20
#description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
chmod +x /etc/init.d/nginx
chkconfig --add nginx
service nginx start
yum -y install ncurses-devel gcc gcc-c++ cmake
tar xzvf mysql-5.5.24.tar.gz -C /opt
cd /opt/mysql-5.5.24
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/home/mysql/ \
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_SSL=system \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1 \
-DWITH_SSL=bundled
make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig mysqld on
service mysqld start
echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
. /etc/profile #更新环境变量
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /usr/local/mysql
> /usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
vim /etc/init.d/mysqld
#修改以下路径
basedir=/usr/local/mysql
datadir=/home/mysql
service mysqld restart
yum -y install gd libxml2-devel libjpeg-devel libpng-devel zlib-devel fontconfig-devel openssl-devel bzip2-devel
tar -jxvf php-5.4.5.tar.bz2 -C /opt
cd /opt/php-5.4.5/
./configure \
--prefix=/usr/local/php5 \
--with-gd \
--with-zlib \
--with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php5 \
--enable-mbstring \
--with-jpeg-dir \
--with-openssl \
--disable-ipv6 \
--enable-fpm
make && make install
cp php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/* /usr/local/bin/
ln -s /usr/local/php5/sbin/* /usr/local/sbin/
#解压软件包
tar xzvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz -C /opt
#进入ZG目录下
cd /opt/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x
#复制ZendGuardLoader.so至php
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
#结尾处添加以下三行数据
[Zend Guard Loader]
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
#进入php的etc目录下
cd /usr/local/php5/etc/
#创建php-fpm.conf文件
cp php-fpm.conf.default php-fpm.conf
#创建php用户
useradd -M -s /sbin/nologin php
vi php-fpm.conf #修改
pid = run/php-fpm.pid #25行
user = php #140行
group = php #141行
pm.max_children=50 #217行
pm.start_servers = 20 #222行
pm.min_spare_servers = 5 #227行
pm.max_spare_servers = 35 #232行
netstat -tnal | grep 9000
vi /usr/local/nginx/conf/nginx.conf
location ~ .php$ {
root /var/www/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
mkdir -p /var/www/php
vim /var/www/php/index.php
#php配置页
<?php phpinfo(); ?>
service nginx restart
#登录mysql
mysql -u root#创建bbs数据库
mysql> CREATE DATABASE bbs;#把bbs数据库里面所有表的权限授予给bbsuser,并设置密码
mysql> GRANT all ON bbs.* TO ‘bbsuser‘@‘%‘ IDENTIFIED BY ‘admin123‘;#刷新数据库
mysql>flush privileges;
vi /var/www/php/index.php
<?php
$link=mysql_connect(‘192.168.100.5‘,‘bbsuser‘,‘admin123‘);
if($link) echo "Success!!";
else echo "Fail!!";
mysql_close();
?>
通过客户端测试如下图即成功
unzip Discuz_X2.5_SC_UTF8.zip -d /opt/discuz
cd /opt/discuz
cp -r upload/ /var/www/php/bbs
> chown -R php ./config
chown -R php ./data
chown -R php ./uc_client
chown -R php ./uc_server/data
标签:nmp connect 反向 php.ini bst web /etc eve utf8
原文地址:http://blog.51cto.com/10316297/2131072