centos 7 安裝系統(tǒng)+安裝php環(huán)境

1 下載centos7.2 鏡像

2 制作啟動(dòng)u盤

下載 ultraiso
選擇iso文件用ultraiso 點(diǎn)擊寫入磁盤映像

3 安裝系統(tǒng)

開機(jī)啟動(dòng)按f12 選擇u盤
進(jìn)入系統(tǒng)選擇第一個(gè) 按e

將vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改為:
 vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quiet 

ok一步一步走 走到

Paste_Image.png

設(shè)置安裝位置 和 選擇軟件選擇里的 桌面版
大工告成·····

4 安裝環(huán)境

初始化系統(tǒng)
設(shè)置軟件源
aliyun , remi, mysql

設(shè)置aliyun庫$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo# 設(shè)置 remi 庫, 設(shè)置 mysql 庫$ yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm# 由于mysql 版權(quán)方面的限制, centos 7 沒有內(nèi)置mysql 服務(wù)器, 必須從mysql 官方進(jìn)行安裝$ yum install http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

設(shè)置 nginx 源

源地址: nginx: Linux packages創(chuàng)建 vi/etc/yum.repos.d/nginx.repo
, 并且填充以下內(nèi)容來安裝 yum repository 庫
[nginx]name=nginx repobaseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/gpgcheck=0enabled=1

替換OS
為 “rhel” 或 “centos”替換OSRELEASE
為 5”, “6”, 或“7”
更新元數(shù)據(jù)

更新元數(shù)據(jù)$ yum makecache

安裝軟件
常用軟件和nmp 軟件

更新系統(tǒng)$ yum update# 安裝常用軟件$ yum install vim git supervisor redis# 安裝 php 基于 remi , 所以需要安裝 remi 源$ yum install --enablerepo=remi-php70 php php-pdo php-fpm php-mbstring php-mcrypt php-gd php-mysqli php-zip# 安裝 nginx$ yum install nginx --enablerepo=nginx# 安裝 mysql server$ yum install mysql-server

啟動(dòng)服務(wù)

啟動(dòng)服務(wù)$ systemctl start php-fpm mysqld nginx supervisord

開機(jī)自啟動(dòng)

開機(jī)啟動(dòng)$ systemctl enable php-fpm mysqld nginx supervisord

初始化數(shù)據(jù)庫
啟動(dòng)mysql并且獲取密碼
$ systemctl start mysqld# mysql 5.7 在安裝完成的時(shí)候會(huì)生成一個(gè)臨時(shí)密碼, 我們需要找到錯(cuò)誤日志 /var/log/mysqld.log來獲取這個(gè)臨時(shí)密碼# use below command to see the password:$ grep 'temporary password' /var/log/mysqld.log [Note] A temporary password is generated for root@localhost: _ab3BAKulW?r

**初始化 mysql **
$ mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: ******New password: ******Re-enter new password: ******The 'validate_password' plugin is installed on the server.The subsequent steps will run with the existing configurationof the plugin.Using existing password for root.Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : *Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : YSuccess.Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N... skipping.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N ... skipping.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : YSuccess.All done!

設(shè)置密碼的方法
$ mysql -uroot -p******mysql> set password for 'root'@'localhost' = password('markzhao123456');mysql> exit

軟件配置
配置nginx
配置 nginx 時(shí)候的運(yùn)行組

/etc/nginx/nginx.confuser nginx nginx;

配置nginx虛擬主機(jī)
server{ listen 80; # 如果這里是 IP, 則才會(huì)允許訪問, 否則, 扯破牛蛋也訪問不到 server_name www.domain.com ; index index.php index.html index.htm default.html default.htm default.php; root /webdata/www/domain/public; # 這里注意和服務(wù)器自帶不同的是 # fastcgi_param SCRIPT_FILENAME /scripts/$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 會(huì)導(dǎo)致 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream 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; } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .*.(js|css)?$ { expires 12h; } access_log /webdata/logs/domain_access.log; error_log /webdata/logs/domain_error.log;}

配置php
配置 php-fpm

/etc/php-fpm.d/www.confuser = nginxgroup = nginx

配置 php.ini

時(shí)區(qū)date.timezone = Asia/Shanghai

配置 session 是可寫狀態(tài)
$ chown -R nginx:nginx /var/lib/php/session/

配置系統(tǒng)允許訪問

配置 http$ firewall-cmd --permanent --zone=public --add-service=http# 配置 3306$ firewall-cmd --permanent --zone=public --add-port=3306/tcp# 重啟 防火墻$ firewall-cmd --reload

配置數(shù)據(jù)庫用戶
CREATE USER 'remote'@'%' IDENTIFIED WITH mysql_native_password AS 'UOSy)iKk$XO9dMB';GRANT ALL PRIVILEGES ON . TO 'remote'@'%' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;GRANT ALL PRIVILEGES ON 1dailian\_v2. TO 'remote'@'%' WITH GRANT OPTION;FLUSH PRIVILEGES

補(bǔ)充
下載安裝mysql
獲取最新下載地址:http://dev.mysql.com/downloads/mysql/
下載地址:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.13-1.el7.i686.rpmhttp://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.13-1.el7.i686.rpm

下載$ wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.13-1.el7.i686.rpm$ wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.13-1.el7.i686.rpm# 安裝yum localinstall mysql-community-client.rpmyum localinstall mysql-community-server.rpm

參考文章
How To Install Nginx on CentOS 7(很及時(shí), 解決了無法使用IP連接上服務(wù)器的問題)
Nginx安裝(官網(wǎng)翻譯)
nginx FastCGI錯(cuò)誤Primary script unknown解決辦法

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容