在CentOS上实现PhpStorm的自动化部署通常涉及以下几个步骤:
# 安装MySQL
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum install mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server
systemctl start mysqld
systemctl enable mysqld
# 安装Nginx
yum install gcc-c++ zlib openssl openssl-devel
mkdir /usr/local/nginx
cd /usr/local/nginx
wget http://nginx.org/download/nginx-1.21.4.tar.gz
tar -zxvf nginx-1.21.4.tar.gz
cd nginx-1.21.4
./configure
make && make install
# 安装PHP
yum install epel-release
yum install gcc automake autoconf libtool make gcc-c++ glibc libmcrypt
/usr/local/nginx/conf/nginx.conf
,在配置文件中添加以下内容:server {
listen 80;
server_name your_domain_or_ip;
root /path/to/your/php/project;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ = 404;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重启Nginx以应用更改:
systemctl restart nginx
# 创建一个名叫jouzeyu的用户
adduser jouzeyu
# 给git用户添加权限
mkdir /home/git
cd /home/git
mkdir .ssh
touch authorized_keys
cd .ssh
cat ~/.ssh/id_rsa.pub # 复制公钥到authorized_keys文件
mkdir /www/wwwroot/git
cd /www/wwwroot/git
git init --bare website.git
chown -R git:git website.git
mkdir /www/wwwroot/test
cd /www/wwwroot/test
git clone /www/wwwroot/git/website.git
chown -R git website
在PhpStorm中配置Deployment:
打开PhpStorm,转到 File > Settings
。
选择 Build, Execution, Deployment > Deployment
,点击 Configuration...
按钮。
点击 +
图标以添加一个新的服务器配置,选择 SFTP
作为连接类型。
填写服务器的地址、端口、用户名和密码等信息。
在 Mappings
选项卡中,指定本地项目文件夹与服务器上项目文件夹之间的映射关系。
点击 OK
保存配置。
通过以上步骤,你就可以在CentOS上使用PhpStorm进行自动化部署了。如果在配置过程中遇到问题,可以参考PhpStorm的官方文档或相关社区论坛寻求帮助。