首先更新系統軟件php
1html |
|
1.安裝nginx源nginx
1sql |
|
2.安裝nginxvim
1centos |
|
3.啓動nginxsocket
1 |
|
Redirecting to /bin/systemctl start nginx.service
4.訪問http://你的ip/
若是成功安裝會出來nginx默認的歡迎界面
RPM安裝MySQL:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpmyum install -y mysql-community-server
成功安裝以後重啓mysql服務:
service mysqld restart 或 systemctl restart mysqld.service
初次安裝mysql是root帳戶是沒有密碼的:
mysql -u root -p 遇到密碼提示,回車便可進入
1. 下載源碼包並解壓:
wget http://cn2.php.net/distributions/php-5.6.3.tar.gz
tar zxvf php-5.6.3.tar.gz
cd php-5.6.3
2.安裝依賴輸入命令
yum
install
libxml2 libxml2-devel openssl openssl-devel
bzip2
bzip2
-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
注意:libmcrypt 和libmcrypt依賴沒法安裝,本身能夠去網上找解決辦法
3. 配置
./configure --with-libdir=lib64 --prefix=/usr/local/php --with-mysql --with-mysqli --with-pdo-mysql --enable-inline-optimization --enable-fpm --with-freetype-dir --with-gd --with-zlib --with-png-dir --with-jpeg-dir --enable-mbstring --with-iconv --enable-sockets --with-curl --with-openssl --enable-pcntl --enable-soap
4. 編譯安裝:
make && make install
5.添加 PHP 命令到環境變量
1 |
|
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改動當即生效執行
1 |
|
或
1 |
|
查看環境變量
1 |
|
查看php版本
1 |
|
6.配置php-fpm
$ cp php.ini-production /etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
7.啓動php-fpm
1 |
|
八、輸入命令
cd /etc/conf.d
vi default.conf
配置根目錄:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/www; //根目錄
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/www; //根目錄
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/www; //根目錄
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
重啓nginx
service nginx reload
在根目錄寫一段程序,測試數據庫