Linux下部署PHP_YAF框架

122 阅读2分钟

                                        Linux下部署PHP_YAF框架

这是之前用富文本写的,格式有点乱,我用markdown优化了一下,请移步至 Linux下从零搭建WordPress  查看  

   
[基本命令]
#pwd    //当前路径
#ls        //当前路径下的所有内容
#find / -name nginx.conf     //查找nginx.conf文件所在的位置
#php -v         //php版本
#php -m         //php扩展

[Linux下安装apache]
(1)安装apache
#yum install httpd
(2)设置自启
#systemctl enable httpd.service

[Linux下安装Mysql]
(1)安装Mysql
#wget repo.mysql.com//mysql57-co…
#rpm -Uvh mysql57-community-release-el7-7.noarch.rpm
#yum install mysql-community-server
#yum install mysql-community-client
(2)修改默认mysql密码
1)查看mysql默认密码命令
#grep 'temporary password' /var/log/mysqld.log
2)登录mysql[登录MYsql(叫我们输入password时直接输,密码不会显示)]
#mysql -uroot -p
3)修改root密码(一定要数字,字母,特殊字符,否则不给过)
#ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test&2018!bbb';
(3)设置mysql root用户能过远程访问(可以在windows用图形化软件(navicat premium)连接)
#service mysqld restart        //重启mysql start|stop|restart
#show databases;            //查看数据库
#use mysql;                    //使用mysql表
#UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;     //更改用户表[允许所有的ip远程访问]
#flush privileges;            //强制刷新权限

[Linux下安装PHP]

首先要更新yum源,不然是默认的老版本,一般都在5.6及以下,但是php7都出来好久了,性能提升50%以上!

      (1)查看Linux CentOS 版本命令   # cat /etc/redhat-release

      (2)

      CentOS版本7.0+:

          rpm -Uvh dl.fedoraproject.org/pub/epel/ep…

          rpm -Uvh mirror.webtatic.com/yum/el7/web…

     CentOS版本6.0+:

           rpm -Uvh dl.fedoraproject.org/pub/epel/ep…

           rpm -Uvh mirror.webtatic.com/yum/el6/lat…

    (3)直接yum安装php7.0了,可以安装的拓展如下:

        yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel

    (3)安装命令(安装了一些扩展 redis,mysqlnd...)
#yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
#yum install -y memcached redis
(4)启动PHP
#systemctl start php-fpm

[Linux下安装nginx]
(1)安装nginx
#rpm -Uvh nginx.org/packages/ce…
#yum install nginx
(2)启动nginx
#service nginx start
#systemctl start nginx
(3)nginx.conf配置项目路径,yaf的默入口是public文件夹下面的index.php文件
nginx.conf配置文件内容:
配置端口为8081,项目路径为/var/www/web/shop/public
server {
listen       8081;
server_name  localhost;

#charset koi8-r;
#access_log  logs/host.access.log  main;

fastcgi_buffer_size 1M;
fastcgi_buffers 32 512k;
fastcgi_busy_buffers_size 1M;

root   /var/www/web/shop/public;

location / {        
index  index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)  /index.php?$1 last;
}
}

#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   html;
}
location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;

}
}

[开始结束命令]
(1)service application status     => 命令符  应用 状态
1)命令符  service
2)应用       nginx|php-fpm|mysql/mysqld|apache|httpd
3)状态      start|stop|reload|restart|status|help
(2)systemctl 命令使用
# systemctl                #输出已激活单元
# systemctl list-units        #输出已激活单元
# systemctl --failed            #输出运行失败的单元
# systemctl list-unit-files        #查看所有已安装服务
# systemctl start nginx        #启动nginx
# systemctl stop nginx        #停止nginx
# systemctl restart nginx        #重启nginx
# systemctl reload nginx        #重新加载nginx配置
# systemctl status nginx        #输出nginx运行状态
# systemctl is-enabled nginx    #检查nginx是否配置为自动启动
# systemctl enable nginx        #开机自动启动nginx
# systemctl disable nginx        #取消开机自动启动nginx
# systemctl help nginx        #显示nginx的手册页
# systemctl daemon-reload        #重新载入 systemd,扫描新的或有变动的单元
# systemctl reboot            #重启
# systemctl poweroff            #退出系统并停止电源
# systemctl suspend            #待机
# systemctl hibernate        #休眠
# systemctl hybrid-sleep        #混合休眠模式(同时休眠到硬盘并待机
# systemctl isolate graphical.target    #等价于telinit 3 或 telinit 5

[安装PHP扩展遇到的问题] 安装PHP扩展要注意扩展的版本号和php的版本号是否对应
(1)configure: error: no acceptable C compiler found in $PATH   [安装GCC软件套件]
#yum install gcc-c++ libstdc++-devel
#y         (确定)

(2)Cannot find OpenSSL's <evp.h>
#yum install openssl openssl-devel
#y        (确定)