安装完libevent之后 [iyunv@wang nginx-1.6.0]# ./configure --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --with-pcre [iyunv@wang nginx-1.6.0]# make && mkae install [iyunv@wang nginx-1.6.0]# vim /etc/profile 加入路径 [iyunv@wang nginx-1.6.0]# . /etc/profile [iyunv@wang nginx-1.6.0]# nginx -t 测试缺少文件 [iyunv@wang nginx-1.6.0]# mkdir -pv /var/tmp/nginx/client/ [iyunv@wang nginx-1.6.0]# nginx -t [iyunv@wang nginx-1.6.0]# nginx [iyunv@wang nginx-1.6.0]# netstat -tupln |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 27414/nginx 控制脚本写入 [iyunv@wang mysql]# cd /etc/init.d/ [iyunv@wang init.d]# vim nginxd [iyunv@wang init.d]# chmod a+x nginxd 加入可执行权限
prog=/usr/local/nginx/sbin/nginx lockfile=/var/lock/nginx.lock # description: the nginx web server # chkconfig: 2345 88 44 . /etc/init.d/functions start(){ if [ -e $lockfile ];then echo "the nginx web server is started" else echo -n "the nginx web server is starting....." sleep 1 $prog && echo "ok" && touch $lockfile || echo "failer" fi } stop(){ if [ ! -e $lockfile ];then echo "the nginx web server is stoped" else echo -n "the nginx web server is stoping....." killproc nginx && echo "ok" && rm -rf $lockfile || echo "failer" fi
}
case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: start|stop|restart" ;; esac 编辑脚本如此,保存退出 进行测试 [iyunv@wang init.d]# pkill -9 nginx 杀死进程 [iyunv@wang init.d]# chkconfig --add nginxd 加入启动 [iyunv@wang init.d]# chkconfig --list |grep nginx 差看 [iyunv@wang init.d]# service nginxd start Nginx与php进行结合 [iyunv@wang php-5.5.8]# vim /etc/nginx/nginx.conf
将这些打开修改
[iyunv@wang php-5.5.8]# cd /usr/local/nginx/html/ 进入目录做个网页测试 [iyunv@wang html]# vim index.php
[iyunv@wang html]# nginx -t 语法测试
利用源码进行apache mysql php安装 先下载mysql源码, 然后解压进行安装 在之前先建个mysql账号mysql组(有了则不需要建立) [iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libmcrypt* libtool* -y 安装 [iyunv@wang ~]# groupadd mysql [iyunv@wang ~]# useradd -r -g mysql mysql [iyunv@wang ~]# rpm -qa |grep mysql 查看之前安装 与mysql想关的包,删除 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media remove mysql-libs 软件包移除 [iyunv@wang ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local 进行解压 [iyunv@wang ~]# cd /usr/local/src cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 进行编译 make && make install 编译安装 [iyunv@wang local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql 做个链接 [iyunv@wang local]# cd mysql [iyunv@wang mysql]# vim INSTALL-BINARY 可以查看帮助文件进行安装 shell> groupadd mysql shell> useradd -r -g mysql mysql shell> cd /usr/local shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz shell> ln -s full-path-to-mysql-VERSION-OS mysql shell> cd mysql shell> chown -R mysql . shell> chgrp -R mysql . shell> scripts/mysql_install_db --user=mysql shell> chown -R root . [iyunv@wang mysql]# chown -R mysql:mysql . 改变当前目录所有者与所有组为mysql [iyunv@wang mysql]# ./scripts/mysql_install_db --user=mysql 进行安装 如果出现这样的错误就需要安装libaio [iyunv@wang mysql]# yum --disablerepo=* --enablerepo=c6-media install libaio libaio-devel -y 进行安装 [iyunv@wang mysql]# ./scripts/mysql_install_db --user=mysql 重新安装 [iyunv@wang mysql]# cd data/ [iyunv@wang data]# ll mysql/ 查看mysql目录下是否有数据,有数据的话表明安装成功 [iyunv@wang data]# cd .. 进入mysql目录 、 [iyunv@wang mysql]# chown -R root . 改变当前所有用户为管理员 [iyunv@wang mysql]# chown -R mysql data/ 将data用户改为mysql [iyunv@wang mysql]# cp my.cnf /etc/ copy文件到my.cnf [iyunv@wang mysql]# cd support-files/ [iyunv@wang support-files]# cp -p mysql.server /etc/init.d/mysqld 复制mysql文件到mysqld下
[iyunv@wang support-files]# service mysqld start 测试是否能够启动 [iyunv@wang mysql]# vim /etc/profile 修改配置文件
PATH=$PATH:/usr/local/mysql/bin 添加此语句 [iyunv@wang mysql]# . /etc/profile 重新读取 [iyunv@wang mysql]# mysql 进入mysql [iyunv@wang mysql]# mysqladmin -u root -p password '123' 设置mysql密码 [iyunv@wang mysql]# chkconfig --add mysql 启动系统启动 [iyunv@wang mysql]# chkconfig mysqld on [iyunv@wang mysql]# vim /etc/ld.so.conf.d/mysql.conf 编辑mysql配置文件
写入此路径 [iyunv@wang mysql]# ldconfig 刷新缓存 [iyunv@wang mysql]# ldconfig -pv |grep mysql 查看结果
[iyunv@wang mysql]# cd /usr/include/ 进入目录 [iyunv@wang include]# ln -s /usr/local/mysql/include/ mysql 做一个链接 [iyunv@wang mysql]# vim /etc/man.config 处理man手册
MANPATH /usr/local/mysql/man 加入即可 [iyunv@wang mysql]# man mysql 进行测试 Mysql处理成功 Php安装 需要安装的包 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install libcm12-devel libjpeg-turbo-devel libpng-devel freetype-devel -y root@wang ~]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src/ 解压软件包 [iyunv@wang ~]# cd /usr/local/src/php-5.5.8/ [iyunv@wang php-5.5.8]# ./configure > --prefix=/usr/local/php > --enable-fpm > --enable-sockets > --with-mysql=/usr/local/mysql > --with-pdo-mysql=/usr/local/mysql > --with-mysqli=/usr/local/mysql/bin/mysql_config > --enable-mbstring > --enable-xml > --with-png-dir > --with-gd > --with-jpeg-dir > --with-zlib > --with-freetype-dir > --with-config-file-path=/etc/php > --with-config-file-scan-dir=/etc/php5.d 配置安装 出现 需要安装[iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install libjpeg* -y 出现
需要安装[iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install libpng-devel -y 出现
需要安装 [iyunv@wang Packages]# yum --disablerepo=* --enablerepo=c6-media install freetype* -y 出现什么就 rpm -qa |grep 包名 找到包安装其devel包即可
接下来需要make && make isntall 因为时间比较长,睡眠的时候可能连接断开所以需要screen来实现安装 [iyunv@wang ~]# yum --disablerepo=* --enablerepo=c6-media install screen -y 安装screen [iyunv@wang php-5.5.8]# screen 使用screen 又打开了一个窗口 ctrl+a+d可以离开 screen -ls可以查看 恢复的话 screen -r 编号 [iyunv@wang php-5.5.8]# make && make install 然后进行后台配置安装 因为要把php座位单独的服务器,所以需要 [iyunv@wang php-5.5.8]# cd sapi/ [iyunv@wang sapi]# cd fpm/ [iyunv@wang fpm]# grep -E "start|stop|restart" * 查找哪个文件是配置文件 [iyunv@wang fpm]# cp init.d.php-fpm /etc/init.d/php-fpm 将配置文件拷贝到php-fpm目录 [iyunv@wang fpm]# chmod a+x /etc/init.d/php-fpm 给予可执行权限 [iyunv@wang fpm]# service php-fpm start 尝试启动下
显示缺少配置文件 [iyunv@wang fpm]# cd /usr/local/php/ [iyunv@wang php]# cd etc/ 进入安装目录 [iyunv@wang etc]# cp php-fpm.conf.default php-fpm.conf 将默认配置文件拷贝成正式的配置文件 [iyunv@wang etc]# service php-fpm start 再次重启下 [iyunv@wang etc]# netstat -tupln|grep php tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8885/php-fpm 查找php-fpm进程是9000.端口说明正确安装 [iyunv@wang etc]# chkconfig --add php-fpm 加入指定启动阵列 [iyunv@wang etc]# chkconfig php-fpm on 加入开机启动 [iyunv@wang etc]# mkdir /etc/php /etc/php5.d 创建2个目录 [iyunv@wang etc]# cd /usr/local/src/php-5.5.8/ 进入php源码目录 [iyunv@wang php-5.5.8]# ll |grep ini 查找是否有与ini相关的文件 [iyunv@wang php-5.5.8]# cp php.ini-production /etc/php/php.ini 将文件拷贝到php目录下 [iyunv@wang php-5.5.8]# service php-fpm restart 重新启动php-fpm 总测试: [iyunv@wang html]# service iptables stop [iyunv@wang html]# setenforce 0
成功访问 查看能否访问数据库 [iyunv@wang html]# vim index.php 修改网页文件
成功 进行压力测试 [iyunv@wang html]# vim index.php 修改网页文件
[iyunv@wang html]# yum --disablerepo=* --enablerepo=c6-media install httpd-tools -y 安装压力测试工具 [iyunv@wang html]# ab -n 10000 -c 1000 http://127.0.0.1/index.php
使用xcache实现缓存,加大抗压能力 [iyunv@wang ~]# tar -zxvf xcache-3.1.0.tar.gz -C /usr/local/src/ [iyunv@wang ~]# cd /usr/local/src/xcache-3.1.0/ [iyunv@wang xcache-3.1.0]# /usr/local/php/bin/phpize 使用php工具实现php扩展 [iyunv@wang xcache-3.1.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 进行配置 [iyunv@wang xcache-3.1.0]# make && make install 配置安装 [iyunv@wang xcache-3.1.0]# cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so /etc/php5.d/ 拷贝模块 [iyunv@wang xcache-3.1.0]# cp xcache.ini /etc/php5.d/ [iyunv@wang xcache-3.1.0]# service php-fpm restart 重启php
有了xcache模块 在进行压力测试 [iyunv@wang html]# ab -n 10000 -c 1000 http://127.0.0.1/index.php
速度明显加快
|