參考:http://www.cnblogs.com/AloneSword/archive/2013/03/18/2966750.html (總結並簡要)php
一安裝cmakehtml
wget -c http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz mysql
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
.boostarp (有這個命令就執行,不然就跳過)
make
make install
cmake --versionlinux
二安裝mysqlnginx
yum -y install gcc libxml2-dev curl screen \
libpng12-dev autoconf libpcre3-dev make bzip2 \
libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \
libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz \
openssl openssl-devel ncurses ncurses-develsql
# 建立用戶和組
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
# 建立安裝目錄
mkdir /usr/local/ mysql
# 建立數據庫目錄
mkdir /usr/local/ mysql/data
# 解壓
tar -zxvf mysql-5.5.17.tar.gz
cd mysql-5.5.17
# 編譯及安裝mysql
# cmake編譯: 數據庫
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
PS: cmake的時候,參數能夠不用那麼多,只要一個-DCMAKE_INSTALL_PREFIX=/usr/local/mysql就好了,咱們能夠在 my.cnf裏面配置。[mysqld]中的內容,看看你copy後的my.cnf有沒有這些設置,有就不用了在設置了。 vim
或
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
api
# 安裝mysql
make && make installbash
# 複製配置文件
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
或
cp support-files/my-medium.cnf /etc/my.cnf
# 設置權限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
# 配置開機自啓動
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfg mysqld on
# 修改my.cnf配置
vim /etc/my.cnf
# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
# 如下可選:
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
# 初始化數據庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
# 啓動MySQL
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
或者:
/etc/init.d/mysql start (service mysql start)
# 測試MySQL是否啓動
# 1)查看是否有進程mysql
ps -ef | grep mysql
# 2)查看端口是否運行
netstat -tnl | grep 3306
# 3)讀取mysql版本信息
/usr/local/mysql/bin/mysqladmin version
初使密碼
#> service mysqld stop
#>mysqld_safe --skip-grant-tables &
輸入 mysql -uroot -p 回車進入
或
編輯my.cnf
在[mysqld] 配置部分添加一行
skip-grant-tables
>use mysql;
> update user set password=PASSWORD("newpass")where user="root";
更改密碼爲 newpassord
> flush privileges; 更新權限
> quit 退出
service mysqld restart
mysql -uroot -p新密碼進入
或
//啓動mysql server在後臺運行
#./bin/mysqld_safe --user=mysql &
設置密碼
# ./bin/mysqladmin -u root password 'passwd'
//進入mysql
# ./bin/mysql -u root -p
二安裝php
參考:http://www.phperz.com/article/14/1207/39774.html
準備:
yum -y install gcc automake autoconf libtool make
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \
--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \
--with-gd --with-jpeg-dir
cp php.ini.production /usr/local/php/etc
啓動
/usr/local/php/sbin/php-fpm
-t
/usr/local/php/sbin/php-fpm
-c
/usr/local/php/etc/php
.ini -y
/usr/local/php/etc/php-fpm
.conf -t
報錯:
configure: error: Please reinstall the BZip2 distribution
解決
yum -y install bzip2 bzip2-devel
報錯:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解決
yum -y install libcurl licurl-devel
報錯:
/usr/local/src/php-5.3.8/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
解決:
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.而後運行/sbin/ldconfig
還不行再加一個
find / -name "libmysqlclient.so.18"
echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
tail -1 /etc/ld.so.conf
ldconfig
這樣就ok了它就能找到庫文件了
添加環境變量
vim /etc/profile
export PATH="$PATH:/usr/local/php/sbin"
啓動服務
/usr/local/php/sbin/php-fpm
報錯:
安裝Nginx時報錯
./configure: error: the HTTP rewrite module requires the PCRE library.
安裝pcre-devel解決問題
yum -y install pcre-devel
加入環境變量
vim /etc/profile
export PATH="$PATH:/usr/local/nginx/sbin"
配置:
#vim /usr/local/nginx/conf/fastcgi_params
if ($fastcgi_script_name ~ "\..*\/.*\.php") {
return 404;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#腳本文件請求的路徑 fastcgi_param QUERY_STRING $query_string; #請求的參數;如?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; #請求的地址不帶參數 fastcgi_param DOCUMENT_URI $document_uri; #與$uri相同。 fastcgi_param DOCUMENT_ROOT $document_root; #網站的根目錄。在server配置中root指令中指定的值 fastcgi_param SERVER_PROTOCOL $server_protocol; #請求使用的協議,一般是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; #服務器IP地址 fastcgi_param SERVER_PORT $server_port; #服務器端口 fastcgi_param SERVER_NAME $server_name; #服務器名,域名在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; 在php可打印出上面的服務環境變量 如:echo $_SERVER['REMOTE_ADDR']
參考:http://www.cnblogs.com/rnckty/p/4832213.html
http://blog.hackroad.com/operations-engineer/linux_server/1453.html