Couldn't resolve host 'mirrors.163.com
//update by 2014.05.22
编译php 5.5.12出现的问题
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
vi /etc/ld.so.conf.d/local.conf # 编辑库文件 /usr/local/lib # 添加该行 :wq # 保存退出 ldconfig -v # 使之生效
注意事项:
这里添加的库文件路径一定要和你系统平台arch一致,32bit的系统直接添加/usr/local/lib即可,64bit系统要填加/usr/local/lib64.否则依旧会报错,我当时就是添加了/usr/local/lib死活编辑不了,后来更改为
/usr/local/lib64才可以
如果还出现就运行下面的
export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib
解决办法添加下面
vim /etc/resolv.conf
nameserver 8.8.8.8
2.http://www.9php.net/article/20130421195412.html
http://centos.ustc.edu.cn/ 教育yum资源地址
1、先备份 /etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、进入 http://mirrors.163.com/.help/centos.html 下载 CentOS6-Base-163.repo,放入 /etc/yum.repos.d/ 。
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3、运行 yum makecache 生成缓存
3.linux终端命令 上传文件到服务器
yum install openssh-clients
scp -P 端口号 -r CentOS6-Base-163.repo 用户名@IP:/home/xiecl
在此列出scp的使用方法 引用
http://www.vpser.net/manage/scp.html
yum -y install gcc gcc-c++ make cmake zlib zlib-devel ncurses-devel ncurses bison
//nginx
./configure --prefix=/usr/local/webserver/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/home/xiecl/openssl-1.0.1 --with-pcre=/home/xiecl/ss/pcre-8.33
//设置开机启动脚本
======================================================= #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/webserver/nginx/conf/nginx.conf nginxd=/usr/local/webserver/nginx/sbin/nginx nginx_config=/usr/local/webserver/nginx/conf/nginx.conf nginx_pid=/usr/local/webserver/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/webserver/nginx/logs/nginx.pid } reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL =======================================================
/usr/local/webserver/nginx/sbin/nginx #启动nginx
groupadd www #添加www组
useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统
设置nginx开启启动
vi /etc/rc.d/init.d/nginx #编辑启动文件添加以上内容
chmod a+x /etc/rc.d/init.d/nginx
vi /etc/rc.local
加入一行 /etc/rc.d/init.d/nginx start 保存并退出,下次重启会生效。
二、安装mysql
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数据库目录权限
mkdir -p /usr/local/webserver/mysql #创建MySQL安装目录
cd /home/xiecl/mysql-5.6.13
tar zxvf mysql-5.6.13.tar.gz #解压
cd mysql-5.6.13
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc
make && make install
cp ./support-files/my-default.cnf /etc/my.cnf (注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
vi /etc/my.cnf
./scripts/mysql_install_db -user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
vi /etc/rc.d/init.d/mysqld
basedir=/usr/local/webserver/mysql
datadir=/usr/local/webserver/mysql/data
service mysqld start #启动
vi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/webserver/mysql/bin
:wq! #保存退出
ln -s /usr/local/webserver/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/webserver/mysql/include/mysql /usr/include/mysql
mysql_secure_installation #设置Mysql密码
根据提示按Y 回车
然后输入2次密码
继续按Y 回车,直到设置完成
或者直接修改密码/usr/local/webserver/mysql/bin/mysqladmin -u root -p password “123456″ #修改密码
安装php
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib
ldconfig
yum install -y php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel libxml2-devel openssl openssl-devel libcurl libcurl-devel libpng-devel
yum install freetype freetype-devel
configure: error: Cannot find ldap.h
yum install openldap yum install openldap-devel
cp -frp /usr/lib64/libldap* /usr/lib/
libmcrypt 编译安装
解决1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行/sbin/ldconfig
错误提示2 cp: cannot stat `ext/phar/phar.phar': No such file or directory
cd ext/phar/
cp ./phar.php ./phar.phar
cp php.ini-production /usr/local/webserver/php/etc/php.ini
ln -s /usr/local/webserver/php/etc/php.ini /etc/php.ini
cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf #编辑
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
pid = run/php-fpm.pid #取消前面的分号
在源码目录下
/home/xiecl/php-5.4.24
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
//disable_functions =
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持php短标签
引用配置地址
http://www.cnblogs.com/eter/p/l_c_6_000006.html
php-fpm启动脚本地址
http://www.lovelucy.info/nginx-phpfpm-init-script.html
#!/bin/bash## Startup script for the PHP-FPM server.## chkconfig: 345 85 15# description: PHP is an HTML-embedded scripting language# processname: php-fpm# config: /usr/local/php/etc/php.ini # Source function library.. /etc/rc.d/init.d/functions PHP_PATH=/usr/localDESC="php-fpm daemon"NAME=php-fpm# php-fpm路径DAEMON=$PHP_PATH/php/sbin/$NAME# 配置文件路径CONFIGFILE=$PHP_PATH/php/etc/php-fpm.conf# PID文件路径(在php-fpm.conf设置)PIDFILE=$PHP_PATH/php/var/run/$NAME.pidSCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed.test -x $DAEMON || exit 0 rh_start() { $DAEMON -y $CONFIGFILE || echo -n " already running"} rh_stop() { kill -QUIT `cat $PIDFILE` || echo -n " not running"} rh_reload() { kill -HUP `cat $PIDFILE` || echo -n " can't reload"} case "$1" in start) echo -n "Starting $DESC: $NAME" rh_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" rh_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." rh_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC: $NAME" rh_stop sleep 1 rh_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2 exit 3 ;;esacexit 0
chmod +x /etc/init.d/php-fpm
/sbin/chkconfig php-fpm on
/sbin/chkconfig --list php-fpm
service php-fpm start service php-fpm stop service php-fpm restart service php-fpm reload /etc/init.d/php-fpm start/etc/init.d/php-fpm stop/etc/init.d/php-fpm restart/etc/init.d/php-fpm reload