一、yum -y update // 更新系統php
1.1)yum -y install gcc g++ gcc-c++ make kernel-devel kernel-headershtml
1.2)vi /etc/selinux/config # 禁止SELINUXmysql
1.3)設置SELINUX=disabledlinux
1.4)重啓系統nginx
二、安裝mysqlc++
2.1)yum -y install mariadb-client mariadb-server mariadb-develweb
2.2)啓動:systemctl start mariadb.serviceredis
2.3)設置開機自啓:systemctl enable mariadbsql
2.4)設置root密碼:shell
① systemctl stop mariadb.service
② mysqld_safe --skip-grant-tables
③ mysql -u root(另開shell)
④ use mysql;
⑤ update user set password=password("123456") where user='root';
⑥ delete from user where user = '';
⑦ flush privileges;
2.5)設置root遠程訪問:
① use mysql;
② update user set host='%' where user='root' and host='localhost';
③ flush privileges;
④ exit;
⑤ systemctl restart mariadb.service
⑥ firewall-cmd --zone=public --add-port=80/tcp --permanent #添加80端口
⑦ firewall-cmd --zone=public --add-port=3306/tcp --permanent #添加3306端口
⑧ firewall-cmd --reload #從新啓動防火牆
三、安裝apache
3.1)yum -y install httpd
3.2)啓動:systemctl start httpd.service
3.3)設置開機自啓:systemctl enable httpd
3.4)配置虛擬主機:在/etc/httpd/conf.d/目錄下建新vhost.conf,新增內容:
<VirtualHost *:80> DocumentRoot "/var/www/html/" ServerName 192.168.8.100 ErrorLog "/var/log/httpd/error.log" CustomLog "/var/log/httpd/access.log" common </VirtualHost> <VirtualHost *:80> DocumentRoot "/var/www/html/CodeIgniter-3.1.2/" ServerName www.100ci.com ErrorLog "/var/log/httpd/100ci-error.log" CustomLog "/var/log/httpd/100ci-access.log" common </VirtualHost>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
附一:yum安裝nginx
# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# yum info nginx
# yum install -y nginx
# systemctl start nginx
# systemctl enable nginx
附二:安裝 nginx 也至關簡單,查看官網說明文檔 http://nginx.org/en/linux_packages.html#stable
1)[root@localhost ~] vi /etc/yum.repos.d/nginx.repo
2)複製以下內容到剛纔新建的文件中
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ # 由於個人系統是centos7 gpgcheck=0 enabled=1
3)yum -y install nginx
4)yum start nginx
5)yum enable nginx
附三:ngnix修改配置文件支持php
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main;
root /var/www/; # 把root從localhost中拿出來,否則$document_root找不到會報404 location / { index index.php 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 /var/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$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
附四:修改/etc/php-fpm.d/www.conf 文件
user = nginx # 由apache改成nginx ; RPM: Keep a group allowed to write in log dir. group = nginx # 由apache改成nginx
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
四、安裝php7
4.1)請參考 https://webtatic.com/packages/php71/
4.2)rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
4.3)rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
4.4) yum -y install php71w php71w-opcache php71w-common php71w-fpm php71w-gd php71w-mbstring php71w-mcrypt php71w-odbc php71w-pecl-redis php71w-pecl-memcached php71w-mysqlnd php71w-devel
4.5)安裝完php,重啓httpd,systemctl restart httpd
4.6)若是php中有衝突的包,執行yum -y remove 包名
五、安裝phpredis、swoole擴展
5.1)yum -y install redis php-redis postgresql-devel openssl-devel
5.2) pecl install swoole
5.2)重啓httpd,systemctl restart httpd
六、部署成功