摘要:腳本名稱請求的地址不帶參數(shù)與相同。在配置中指令中指定的值請求使用的協(xié)議,通常是或。
編譯環(huán)境說明
操作系統(tǒng):Centos
一、Mysql編譯安裝檢查系統(tǒng)是否安裝Mysql
[root@localhost /]# find -name mysql // 如果沒有查找到目錄信息,表示沒有安裝
修改iptables:vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT
重啟iptables
service iptables restart
編譯環(huán)境開始前,先安裝環(huán)境編譯依賴包:
yum -y install make gcc gcc-c++ ncurses-devel pcre-devel zlib-devel
安裝Mysql編譯依賴包
yum install ncurses-devel # 安裝cmake (編譯mysql用) wget http://www.cmake.org/files/v2.8/cmake-2.8.9.tar.gz tar -zxvf cmake-2.8.9.tar.gz cd cmake-2.8.9 ./configure &&make &&make install
開始編譯安裝Mysql
groupadd mysql useradd -g mysql mysql // 添加mysql用戶并加入mysql用戶組 useradd -g mysql mysql -s /bin/false // -s useradd命令的一個參數(shù),使用者登入后使用的shell名稱,此處指定/bin/false mkdir -p /data/mysql // 創(chuàng)建Mysql數(shù)據(jù)目錄 chown -R mysql:mysql /data/mysql // 數(shù)據(jù)目錄用戶組 # 進(jìn)入mysql源碼包目錄 wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz cd /data/soft/mysql/mysql-5.5.27 # 開始編譯mysql cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_TCP_PORT=3306 -DSYSCONFDIR=/etc -DINSTALL_SHAREDIR=share make make install
注:重新運(yùn)行配置,需要刪除CMakeCache.txt文件
初始化Mysql
cp ./support-files/my-medium.cnf /etc/my.cnf /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql /usr/local/mysql/bin/mysqld_safe --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql & cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
Mysql配置開機(jī)啟動(配置完成記得給mysqld 賦執(zhí)行權(quán)限)
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chkconfig --add mysql chkconfig --level 2345 mysql on chown mysql:mysql -R /usr/local/mysql/ service mysql start
Mysql 環(huán)境變量配置
vim /etc/profile // 寫入下面腳本 export PATH="$PATH:/usr/local/php/bin:/usr/local/mysql/bin" source /etc/profile // 環(huán)境變量生效
Mysql用戶密碼修改
/usr/local/mysql/bin/mysqladmin -u root -p password newpassword 1.例如你的 root用戶現(xiàn)在沒有密碼,你希望的密碼修改為123456,那么命令是: mysqladmin -u root password 123456 2.如果你的root現(xiàn)在有密碼了(123456),那么修改密碼為abcdef的命令是: mysqladmin -u root -p password abcdef 注意,命令回車后會問你舊密碼,輸入舊密碼123456之后命令完成,密碼修改成功。
配置Mysql數(shù)據(jù)庫準(zhǔn)許遠(yuǎn)程訪問
# 登錄Mysql /usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -p # 進(jìn)入Mysql表 use mysql; # 查詢表 select Host,User from user limit 10; # 更新表 update user set Host="%" where User="root" and Host="localhost"; # 刷新Mysql權(quán)限 flush privileges;
Mysql 命令行登錄
/usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -p
查看Mysql進(jìn)程/端口
netstat -an |grep 3306 ps -le | grep mysqld ps aux | grep mysqld
SQL修改密碼
update user set password=PASSWORD("woshishui") where user="root";二、Nginx 編譯安裝
安裝前提
[root@admin /]# yum -y install zlib zlib-devel openssl openssl-devel
安裝Nginx# 安裝pcre (支持nginx偽靜態(tài))
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz cd /usr/local/src mkdir /usr/local/pcre // 創(chuàng)建安裝目錄 tar zxvf pcre-8.30.tar.gz cd pcre-8.30 ./configure --prefix=/usr/local/pcre // 配置 make make install
開始安裝Nginx
[root@admin local]# groupadd www #添加www組 [root@admin local]# useradd -g www www -s /bin/false // 不允許www用戶直接登錄系統(tǒng) [root@admin local]# cd /data/soft/ [root@admin local]# wget http://nginx.org/download/nginx-1.6.2.tar.gz [root@admin local]# tar -zxvf nginx-1.6.2.tar.gz [root@admin local]# cd nginx-1.6.2/ [root@admin nginx]# ./configure --prefix=/usr/local/nginx [root@admin nginx]# make [root@admin nginx]# make install
Nginx啟動腳本
#!/bin/bash # nginx This shell script takes care of starting and stopping # nginx # # chkconfig: - 13 68 # description: nginx is a web server ### BEGIN INIT INFO # Provides: $named # Short-Description: start|stop|status|restart|configtest ### END INIT INFO #variables NGINX_BIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" NETSTAT="/bin/netstat" alter=$1 prog=nginx #load system function . /etc/rc.d/init.d/functions #function:echo ok or error function if_no { if [ $2 == 0 ]; then echo -n $"$1 ${prog}:" && success && echo else echo -n $"$1 ${prog}:" && failure && echo fi } #start nginx function start { rm -f ${NGINX_PID} 2>/dev/null if [ -s ${NGINX_PID} ]; then echo "nginx already running" else if [ `${NETSTAT} -tnpl | grep nginx | wc -l` -eq 0 ]; then rm -f ${NGINX_PID} 2>/dev/null ${NGINX_BIN} -c ${NGINX_CONF} if_no start $? else ${NETSTAT} -tnpl | grep nginx | awk "{ print $7}" | cut -d "/" -f 1 > ${NGINX_PID} if_no start $? fi fi } #stp nginx function stop { if [ -s ${NGINX_PID} ]; then cat ${NGINX_PID} | xargs kill -QUIT if_no stop $? else if [ `${NETSTAT} -tnpl | grep nginx | wc -l` -eq 0 ]; then rm -f ${NGINX_PID} 2>/dev/null if_no stop 0 else rm -f ${NGINX_PID} 2>/dev/null kill `${NETSTAT} -tnpl | grep nginx | awk "{ print $7}" | cut -d "/" -f 1` if_no stop $? fi fi } function restart { if [ -s ${NGINX_PID} ]; then cat ${NGINX_PID} | xargs kill -HUP if_no restart $? else stop sleep 1 start fi } function status { ${NETSTAT} -tnpl | grep nginx | grep LISTEN [ $? == 0 ] && echo "nginx is running" || echo "nginx is not running" } function configtest { ${NGINX_BIN} -t } case $alter in start) start ;; stop) stop ;; restart) restart ;; status) status ;; configtest) configtest ;; *) echo "use:${NGINX} {start|stop|restart|status|configtest}" ;; esac
配置Nginx自啟動腳本
[root@admin nginx]# chmod +x /etc/init.d/nginx [root@admin nginx]# /etc/init.d/nginx start 或 service nginx start // 啟動nginx [root@admin nginx]# /etc/init.d/nginx stop 或 service nginx stop // 關(guān)閉nginx [root@admin nginx]# /etc/init.d/nginx restart 或 service nginx restart // 重啟nginx
配置開機(jī)自動啟動
chkconfig --add nginx chkconfig --level 2345 nginx on三、Php 編譯安裝
檢查系統(tǒng)安裝的php
[root@iZ23g4snm6gZ soft]# find -name php
PHP 編譯依賴包安裝
# 注意:freetype在生成驗(yàn)證碼圖片需要用,所以必須要安裝的 [root@iZ23g4snm6gZ soft]# yum install openssl-devel libxml2 libxml2-devel curl-devel libevent [root@iZ23g4snm6gZ soft]# yum install libpng libpng-devel libjpeg libjpeg-devel freetype-devel gd gd-devel # 源碼包安裝libiconv tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14/ ./configure --prefix=/usr/local/libiconv make make install # 源碼包安裝libiconv tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure --prefix=/usr/local/libmcrypt/ make make install
開始編譯PHP(Nginx)
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-zlib --with-libxml-dir --enable-sockets --with-curl --with-jpeg-dir --with-png-dir --with-gd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir= --enable-gd-native-ttf --with-xmlrpc --with-openssl --with-mhash --with-mcrypt=/usr/local/libmcrypt/ --with-pear --enable-mbstring --enable-sysvshm --enable-zip --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock --with-pdo-mysql --disable-fileinfo make make install
設(shè)置PHP配置文件
cp php.ini-production /usr/local/php/etc/php.ini # 拷貝模板文件為php-fpm配置文件 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf vi /usr/local/php/etc/php-fpm.conf // 編輯 user = www // 設(shè)置php-fpm運(yùn)行賬號為www 默認(rèn)賬號為nginx group = www // 設(shè)置php-fpm運(yùn)行組為www pid = run/php-fpm.pid // 取消前面的分號 :wq! // 保存退出
php-fpm啟動腳本
#! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in "created") if [ -f "$2" ] ; then try="" break fi ;; "removed") if [ ! -f "$2" ] ; then try="" break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit 1 ;; esac
設(shè)置php-fpm開機(jī)自啟動
mv php-fpm /etc/init.d/ // 移動php-fpm腳本到init.d目錄下 chmod a+x /etc/init.d/php-fpm // 添加執(zhí)行權(quán)限 chkconfig --add php-fpm // 添加開機(jī)啟動配置 chkconfig --level 2345 php-fpm on // 配置開機(jī)啟動權(quán)限級別四、配置nginx支持php
打開nginx.conf,修改如下:
vim /usr/local/nginx/conf/nginx.conf
nginx.conf文件內(nèi)容:
# 首行user去掉注釋,修改Nginx運(yùn)行組為www www; # 必須與/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否則php運(yùn)行出錯 user www www; worker_processes 1; # 開啟nginx錯誤日志 error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main "$remote_addr - $remote_user [$time_local] "$request" " # "$status $body_bytes_sent "$http_referer" " # ""$http_user_agent" "$http_x_forwarded_for""; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; client_max_body_size 2m; #gzip on; # 包含域名配置文件( 支持通配符) include vhost/*.conf; }
配置 fastcgi.conf文件:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 腳本文件請求的路徑 fastcgi_param QUERY_STRING $query_string; # 請求的參數(shù);如?app=123 fastcgi_param REQUEST_METHOD $request_method; # 請求的動作(GET,POST) fastcgi_param CONTENT_TYPE $content_type; # 請求頭中的Content-Type字段 fastcgi_param CONTENT_LENGTH $content_length; # 請求頭中的Content-length字段。 fastcgi_param SCRIPT_NAME $fastcgi_script_name; # 腳本名稱 fastcgi_param REQUEST_URI $request_uri; # 請求的地址不帶參數(shù) fastcgi_param DOCUMENT_URI $document_uri; # 與$uri相同。 fastcgi_param DOCUMENT_ROOT $document_root; # 網(wǎng)站的根目錄。在server配置中root指令中指定的值 fastcgi_param SERVER_PROTOCOL $server_protocol; # 請求使用的協(xié)議,通常是HTTP/1.0或HTTP/1.1。 fastcgi_param GATEWAY_INTERFACE CGI/1.1; # cgi 版本 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; # nginx 版本號,可修改、隱藏 fastcgi_param REMOTE_ADDR $remote_addr; # 客戶端IP fastcgi_param REMOTE_PORT $remote_port; # 客戶端端口 fastcgi_param SERVER_ADDR $server_addr; # 服務(wù)器IP地址 fastcgi_param SERVER_PORT $server_port; # 服務(wù)器端口 fastcgi_param SERVER_NAME $server_name; # 服務(wù)器名,域名在server配置中指定的server_name #fastcgi_param PATH_INFO $path_info; # 可自定義變量 # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200;
配置虛擬主機(jī)公用配置文件server.conf:
# php文件訪問配置 location ~ .*.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } # 靜態(tài)文件緩存30天 location ~ .*.(gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; # access_log off; } # js,css文件緩存15個小時 location ~ .*.(js|css)?$ { expires 15d; # access_log off; }
配置虛擬主機(jī)文件 vhost/yphp.cn.conf:
server { listen 80; # 配置域名 server_name www.yphp.cn yphp.cn; # 配置網(wǎng)站目錄 root /usr/local/nginx/html/yphp.cn; # 配置域名重定向 if ($host != "www.yphp.cn" ) { rewrite ^/(.*)$ http://www.yphp.cn/$1 permanent; } location / { # 配置rewrite if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } # include /usr/local/nginx/html/yphp/.htaccess; # rewrite ^/(.+)/(.+)[/]?$ /index.php?m=$1&a=$2 last; # 配置默認(rèn)訪問文件 index index.php index.html index.htm; } # 包含虛擬主機(jī)公用配置文件 include server.conf; }測試看看我們的辛苦是否有回報吧
/etc/init.d/nginx stop # 停止nginx 服務(wù) /etc/init.d/nginx start # 啟動nginx 服務(wù)
記得綁定下host文件,然后在瀏覽器輸入我們配置的域名,yphp.cn
總結(jié)這樣我們就源碼包安裝成功了,開始我們的php編程之旅吧,GO GO GO GO GO GO.......時間不早了,該睡覺嘍...............
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/21068.html
摘要:上源碼地址鏈接編譯安裝編譯需要庫支持需要用到它們的頭上,,集成環(huán)境安裝注意指的是源碼路徑注意如果你不指定路徑譬如這樣那說明用的是默認(rèn)路徑需要這么做只是想用 github上源碼地址:鏈接 編譯安裝Nginx 編譯nginx需要pcre, zlib, openssl庫支持(需要用到它們的頭) #!/bin/sh # linux上nginx,php,mysql集成環(huán)境 # Author s...
摘要:上源碼地址鏈接編譯安裝編譯需要庫支持需要用到它們的頭上,,集成環(huán)境安裝注意指的是源碼路徑注意如果你不指定路徑譬如這樣那說明用的是默認(rèn)路徑需要這么做只是想用 github上源碼地址:鏈接 編譯安裝Nginx 編譯nginx需要pcre, zlib, openssl庫支持(需要用到它們的頭) #!/bin/sh # linux上nginx,php,mysql集成環(huán)境 # Author s...
摘要:目前,我們看到的老蔣采用的部署的環(huán)境,在鏡像中配置,于是我們會稱作為。有沒有一件傻瓜式安裝工具腳本呢這里老蔣要推薦的來自國內(nèi)比較老牌且一直更新維護(hù)的一鍵安裝包,我們可以較為直觀且無人值守的安裝需要的網(wǎng)站服務(wù)器環(huán)境。如今我們建站較多的還是會選擇VPS云服務(wù)器,很少會去選擇虛擬主機(jī),固然前者有很多的優(yōu)點(diǎn)。不過相比虛擬主機(jī)不同的是,VPS云服務(wù)器需要我們自己配置WEB環(huán)境,而且我們較多的還是會選擇...
閱讀 3758·2023-04-25 20:00
閱讀 3109·2021-09-22 15:09
閱讀 506·2021-08-25 09:40
閱讀 3412·2021-07-26 23:38
閱讀 2201·2019-08-30 15:53
閱讀 1097·2019-08-30 13:46
閱讀 2788·2019-08-29 16:44
閱讀 2043·2019-08-29 15:32